diff options
author | Kevin Chabowski <kevin@kch42.de> | 2013-10-25 21:44:02 +0200 |
---|---|---|
committer | Kevin Chabowski <kevin@kch42.de> | 2013-10-25 21:44:02 +0200 |
commit | dd03af69265ad686ae8daff6ecbd9df763e6d19f (patch) | |
tree | a86dae876afae2dcea9a3d70e3b513e305b38415 /example/templates/transc/custom_tags.tpl.php | |
parent | 91b965181f907b169aeeff63a6c15f9b8df9d9a9 (diff) | |
parent | eebf5cb885f266104333ac145355ef6e2599e5f6 (diff) | |
download | ste-dd03af69265ad686ae8daff6ecbd9df763e6d19f.tar.gz ste-dd03af69265ad686ae8daff6ecbd9df763e6d19f.tar.bz2 ste-dd03af69265ad686ae8daff6ecbd9df763e6d19f.zip |
Merge branch 'parser2'
STE gets a new, more robust parser. The previous parser was very fragile
and relied on some ugly regular expressions.
Other advantages of the new parser:
* No precompile phase to implement short tags (?{}, ~{}), that means
short tags can now be nested in any order.
* The parses now uses the mb_* functions, so it should handle non-ascii
text correctly.
There were also some improvements to the compiler:
* Various small bugfixes.
* The compiler accepts and compiles tag parameters that have tags in
them. The parser still doesn't accept this (and probably never will),
this is mainly used to allow arbitrary code inside of short cmp tags
(~{..}).
There are now (finally!) tests for the language to maintain a certain
quality and consistency (which STE lacked in the past, to be honest).
And finally the code was reformatted. Now 1TBS is used instead of
Allman.
Diffstat (limited to 'example/templates/transc/custom_tags.tpl.php')
-rw-r--r-- | example/templates/transc/custom_tags.tpl.php | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/example/templates/transc/custom_tags.tpl.php b/example/templates/transc/custom_tags.tpl.php deleted file mode 100644 index b92f8a3..0000000 --- a/example/templates/transc/custom_tags.tpl.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php $transcompile_fx = function($ste) -{ - $outputstack = array(''); - $outputstack_i = 0; - $outputstack[] = ''; - $outputstack_i++; - $outputstack[$outputstack_i] .= "array|value|max"; - $outputstack_i--; - $mandatory_params = explode('|', array_pop($outputstack)); - $tag_fx = function($ste, $params, $sub) use ($mandatory_params) - { - $outputstack = array(); $outputstack_i = 0;$ste->vars['_tag_parameters'] = $params; - foreach($mandatory_params as $mp) - { - if(!isset($params[$mp])) - throw new \ste\RuntimeError("$mp missing in <ste:" . "foreach_limit" . ">."); - }$foreachloop_4f4e9064144651_57761022_arrayvar = @$ste->vars["_tag_parameters"]["array"]; - $foreachloop_4f4e9064144651_57761022_valuevar = @$ste->vars["_tag_parameters"]["value"]; - $foreachloop_4f4e9064144651_57761022_countervar = "i"; - $foreachloop_4f4e9064144651_57761022_array = $ste->get_var_by_name($foreachloop_4f4e9064144651_57761022_arrayvar); - if(!is_array($foreachloop_4f4e9064144651_57761022_array)) - $foreachloop_4f4e9064144651_57761022_array = array(); - $foreachloop_4f4e9064144651_57761022_counter = -1; - foreach($foreachloop_4f4e9064144651_57761022_array as $foreachloop_4f4e9064144651_57761022_key => $foreachloop_4f4e9064144651_57761022_value) - { - try - { - $foreachloop_4f4e9064144651_57761022_counter++; - $ste->set_var_by_name($foreachloop_4f4e9064144651_57761022_countervar, $foreachloop_4f4e9064144651_57761022_counter); - $ste->set_var_by_name($foreachloop_4f4e9064144651_57761022_valuevar, $foreachloop_4f4e9064144651_57761022_value); - - $outputstack[] = ""; - $outputstack_i++; - $outputstack[$outputstack_i] .= (($ste->get_var_by_name("i")) >= ($ste->get_var_by_name("_tag_parameters[max]"))) ? 'yes' : ''; - $outputstack_i--; - if($ste->evalbool(array_pop($outputstack))) - { - throw new \ste\BreakException(); - - } - $outputstack[] = ""; - $outputstack_i++; - $outputstack[$outputstack_i] .= "\n\t\t\t" . @$ste->vars["_tag_parameters"]["counter"]; - $outputstack_i--; - if($ste->evalbool(array_pop($outputstack))) - { - $outputstack[] = ''; - $outputstack_i++; - $outputstack[$outputstack_i] .= @$ste->vars["i"]; - $outputstack_i--; - $ste->set_var_by_name(@$ste->vars["_tag_parameters"]["counter"], array_pop($outputstack)); - - } - $outputstack[$outputstack_i] .= $sub($ste); - } - catch(\ste\BreakException $e) { break; } - catch(\ste\ContinueException $e) { continue; } - - } - - return array_pop($outputstack); - }; - $ste->register_tag("foreach_limit", $tag_fx); - return array_pop($outputstack); -}; ?>
\ No newline at end of file |