dwoo

Is there anything like Dwoo-s {with} or {loop} in Smarty 3 or earlier?

折月煮酒 提交于 2019-12-24 04:03:04
问题 {with} and {loop} plugins in Dwoo template engine change default context for variable name resolution. If in Dwoo you feed template: {$arr.foo} {with $arr} {$foo} / {$arr.foo} {/with} with data: array('arr' => array( 'foo' => 'bar' )) it will output: bar bar / because second {$arr.foo} actually means {$arr.arr.foo} in global context. Do you know how can I achieve similar effect in Smarty? Is there some builit in functionality or third party plugin that might allow me to have this? Do you have

Break in Smarty's / Dwoo's foreach

China☆狼群 提交于 2019-12-21 04:53:28
问题 About break foreach ( $data as $k => $v ) { if ( $k == 4 ) { break; } } every one knows. Is there something similar in Smarty 's or Dwoo 's {foreach} function ? 回答1: You should put your logic in php, not in template. However, you can write your own compiler plugin: function smarty_compiler_break($contents, &$smarty){ return 'break;'; } and save it to compiler.break.php in your plugins directory. Now in template you can use {break} . 回答2: @Antonio: typical PHP developer retort, indeed :) Using

Reassign parent variable in included Dwoo template

穿精又带淫゛_ 提交于 2019-12-11 15:28:57
问题 I have a Dwoo template - in example base.html and there is an array $data . {assign '' 'globalVar'} {* $globalVar empty right now *} {foreach $data element} {include '_partial.html'} {/foreach} ... <b>{$globalVar}</b> And here is _partial.html <p> {$element.someText} </p> {assign "$globalVar $element.someVar" 'globalVar'} What I want to gain ? In every partial file I want to modify some $globalVar that I want to use after {foreach} . And here is an important thing - I do not want to do the

Routing URLs in PHP

落花浮王杯 提交于 2019-11-27 15:10:56
I'm working on a web page project. I decided to use Apache, PHP (5.1.7, version imposed by my service provider) and Dwoo (templating) for this purpose. I want to route URLs to my templates. I'm aware there are many frameworks doing this kind of thing. I'm just wondering if there's a nice way to achieve it without. I've set up my project as follows: src/dwoo - Dwoo files index.php - This should handle routing. Currently it just renders the front page of the site using a template. templates - Templates that represent actual pages. There is minimal amount of business logic (no real model). It's

Routing URLs in PHP

允我心安 提交于 2019-11-26 17:07:17
问题 I'm working on a web page project. I decided to use Apache, PHP (5.1.7, version imposed by my service provider) and Dwoo (templating) for this purpose. I want to route URLs to my templates. I'm aware there are many frameworks doing this kind of thing. I'm just wondering if there's a nice way to achieve it without. I've set up my project as follows: src/dwoo - Dwoo files index.php - This should handle routing. Currently it just renders the front page of the site using a template. templates -