Leser: 4
![]() |
|< 1 ... 53 54 55 56 57 58 59 ... 64 >| | ![]() |
631 Einträge, 64 Seiten |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
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); }
1
2
3
4
5
6
7
8
9
10
11
12
13
<template>
name = Skript
description = Skript-Stub
preprocess = ReneeB
content = <<EOF
#!/usr/bin/perl
use strict;
use warnings;
my $filename = "$(file)";
EOF
</template>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
package ReneeB; use strict; use warnings; sub preprocess{ my ($text) = @_; my $file = Kephra::Document::_get_current_name(); $text =~ s~(?!\\)\$\(file\)~$file~g; return $text; } 1;
lichtkind+2007-11-28 23:41:34--ich glaub was du willst geht son bischen über einfaches templating hinaus, aber die 3 und einige mehr stell ich dir zu den nächsten versionen.
gut erst mal als kompromiss?
![]() |
|< 1 ... 53 54 55 56 57 58 59 ... 64 >| | ![]() |
631 Einträge, 64 Seiten |