sub new_from_template { my $template_name = Kephra::Dialog::get_template(); warn $template_name; return unless $template_name; Kephra::File->new(); my $cfg = $Kephra::config{file}{templates}; my $file = Kephra::Config::filepath($cfg->{directory}, $cfg->{file}); my $tmp = Kephra::Config::File::load( $file ); if (exists $tmp->{template}){ $tmp = Kephra::Config::Tree::_convert_node_2_AoH(\$tmp->{template}); my $untitled = $Kephra::localisation{app}{general}{untitled}; for my $template ( @{$tmp} ) { next unless $template_name eq $template->{name}; my $filepath = Kephra::Document::get_file_path() || "<$untitled>"; my $filename = Kephra::Document::file_name() || "<$untitled>"; my $firstname = Kephra::Document::first_name() || "<$untitled>"; my $content = $template->{content}; $content =~ s/\[\$\$firstname\]/$firstname/g; $content =~ s/\[\$\$filename\]/$filename/g; $content =~ s/\[\$\$filepath\]/$filepath/g; Kephra::Edit::insert_text($content); last; } } }