template-engine

Recursive iteration over an object in Jade template?

↘锁芯ラ 提交于 2019-12-03 12:01:05
问题 I have an object of mixed type properties - some strings, some arrays of strings, some objects containing arrays of strings - that can potentially go many levels deep. I would like to iterate over all properties so that an object creates a div, an array creates a div, and a string property creates a span to contain the text. { "string" : "some text", "object" : { "array" : [ "text" ] } } The above object would render as: <span>some text</span> <div> <div> <span>text</span> </div> </div> But

Access values using {{#each}} in a one dimensional array

纵然是瞬间 提交于 2019-12-03 10:32:01
I've found a lot of examples of using the {{#each}} helper to iterate over multi-dimensional arrays, but I can't figure out how to access each value in a one-dimensional array. For example, take this array: skills: ['Design', 'Development', 'HTML5', 'CSS', 'JavaScript'], How do I output each item, in a helper like below? template: Handlebars.compile( '<div>' + '{{#each skills}} {{ the_item_output }} {{/each}}' + '</div>' ), What do I need to put in placed of {{ the_item_output }} to see the actual item? {{#each skills}} <li>{{this}}</li> {{/each}} An array of scalar values should make use of

Which Java MVC frameworks integrate easily with StringTemplate?

别等时光非礼了梦想. 提交于 2019-12-03 10:14:33
It's hard to see how StringTemplate integrates easily (or not) with popular Java web MVC frameworks. Which Java MVC frameworks integrate easily with StringTemplate? A good answer: mentions one solution to integrate with a framework, includes a link to something useful and applicable, like: a tutorial , or documentation , or a reference to source code : free , and open source or public domain . Readers/Voters , please vote for a solution if you know it's true and great. In the scope of this question, I am not interested in any other templating engine than StringTemplate . I've gotten

advanced string formatting vs template strings

耗尽温柔 提交于 2019-12-03 08:08:43
问题 I was wondering if there is a advantage of using template strings instead of the new advanced string formatting? 回答1: Templates are meant to be simpler than the the usual string formatting, at the cost of expressiveness. The rationale of PEP 292 compares templates to Python's % -style string formatting: Python currently supports a string substitution syntax based on C's printf() '%' formatting character. While quite rich, %-formatting codes are also error prone, even for experienced Python

Smarty PHP clashing with AngularJS

一曲冷凌霜 提交于 2019-12-03 07:25:18
How do I stop Smarty throwing an error when I'm using AngularJS in the same template. I have a Smarty page template with this code: <li ng-repeat="i in items"> <p class="item">{{i}}</p> </li> And I'm getting a blank page when I view in a browser. I get a big error in my apache error_log, which contains the following: PHP Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template ... <p>{{i}}</p>; unknown tag "i If I swap {{i}} for {{4}} or any other digit it works fine. And I can use maths as well, {{8+2}} will show 10 in the page. Is that the Smarty doing

Is there a good HTML template engine in cocoa touch? [closed]

随声附和 提交于 2019-12-03 07:04:42
Closed. This question is off-topic. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it's on-topic for Stack Overflow. In my iphone app, I want to populate UIWebView with some html generated from a templates. Is there a good opensource template engine library for cocoa touch like jinja or smarty? Try MGTemplateEngine . https://github.com/groue/GRMustache is a full implementation of the {{ mustache }} template engine. 来源: https://stackoverflow.com/questions/3915819/is-there-a-good-html-template-engine-in-cocoa-touch

knockout.js loading templates at runtime

故事扮演 提交于 2019-12-03 06:58:25
I am using knockout.js with its inbuilt templating system. I define the templates as so: <script type="text/html" id="subjectItemView"> <span class="name" data-bind="text: subjectName" /> </script> I then use the id of the template so having this as part of the script is a necessity. I have a fair few of these templates in my single page application and have recently moved to using require.js to load the scripts that are required only when they are required. I would like to do the same with the templates, preferably using require.js so that my modules could list the templates as dependencies.

What is the best current Javascript templating engine? [closed]

坚强是说给别人听的谎言 提交于 2019-12-03 06:08:32
So there are a bunch of older questions on this topic that point to a number of options available. These two questions for example are some of the most answered on the topic: What good template language is supported in JavaScript? jQuery templating engines Most of the answers to both questions are from 2008. However in the past year or so the javascript landscape has evolved considerably. For example, the .NET JQuery extensions were recently added as official JQuery plugins. Out of the current templating engines, which is the best one to use? Here are some options I'm aware of: JQuery-tmpl

in velocity can you iterate through a java hashmap's entry set()?

喜你入骨 提交于 2019-12-03 05:28:08
问题 Can you do something like this in a velocity template? #set ($map = $myobject.getMap() ) #foreach ($mapEntry in $map.entrySet()) <name>$mapEntry.key()</name> <value>$mapEntry.value()</value> #end it outputs blank tags like so: <name></name> and <value></value> What am I doing wrong? 回答1: Your mistake is referring to key and value as methods (with trailing "()" parenthesis) instead of as properties. Try this: #set ($map = $myobject.getMap() ) #foreach ($mapEntry in $map.entrySet()) <name>

app.set and app.engine in Express

匆匆过客 提交于 2019-12-03 05:13:47
问题 I am following a Node.js tutorial. Two lines for which I am not sure are: app.set('view engine', 'html'); app.engine('html', hbs.__express); I checked the documentation for app.set and it only tells me: Assigns setting name to value. But my question is what's the relevance of using this. I googled it and wherever app.engine is used app.set is called before. Let me know the significance of using app.set before the app.engine . EDIT I found the following line, but I am still unclear as I am