if ($menu_name eq '&insert_templates') { set_update($menu_id, sub { my $cfg = $Kephra::config{file}{templates}; my $file = Kephra::Config::filepath($cfg->{directory}, $cfg->{file}); my $tmp = Kephra::Config::File::load( $file ); my @menu_data; if (exists $tmp->{template}){ $tmp = Kephra::Config::Tree::_convert_node_2_AoH(\$tmp->{template}); for my $template ( @{$tmp} ) { my %item; $item{type} = 'item'; $item{label}= $template->{name}; $item{call} = sub { my $text = $template->{content}; if( exists $template->{preprocess} ){ my $module = $template->{preprocess}; (my $file = $module) =~ s!::!/!g; $file = $module . '.pm'; eval{ require $file; my $sub = $module->can( 'preprocess' ); if( $sub ){ $text = $sub->( $text ); } }; } Kephra::Edit::insert_text( $text ); }; $item{help}= $template->{description}; push @menu_data, \%item; } } eval_data($menu_id, \@menu_data); }); set_absolete($menu_id); }