How do I execute ruby template files (ERB) without a web server from command line?

You should have everything you need in your ruby/bin directory. On my (WinXP, Ruby 1.8.6) system, I have ruby/bin/erb.bat erb.bat [switches] [inputfile] -x print ruby script -n print ruby script with line number -v enable verbose mode -d set $DEBUG to true -r [library] load a library -K [kcode] specify KANJI code-set -S [safe_level] set … Read more

What are the differences between the express-handlebars, express-hbs and hbs modules,

Looks like the comment above needs to be updated a bit. Updated list is here: Express-handlebars Seems to be the most popular package at the moment. There is live chat on gitter. Dependencies are up-to date and current npm version is 3.0.0. Last update 29 days ago (at the moment of this post) One important … Read more

Check if value in array in angular template?

You can use indexOf() to test whether a value is in an array and then use it inside your ngClass like this (to conditionally add “newclass”): <div ng-class=”{‘newclass’:([1,2,5].indexOf(2) > -1)}”>Yay</div> Or more likely you’ll want to test against an array on your scope: <div ng-class=”{‘newclass’:(tarray.indexOf(1) > -1)}”>Yay</div> Assuming, for instance, you have declared tarray in … Read more

Mako or Jinja2? [closed]

I personally prefer Jinja2’s syntax over Mako’s. Take this example from the Mako website <%inherit file=”base.html”/> <% rows = [[v for v in range(0,10)] for row in range(0,10)] %> <table> % for row in rows: ${makerow(row)} % endfor </table> <%def name=”makerow(row)”> <tr> % for name in row: <td>${name}</td>\ % endfor </tr> </%def> There are so … Read more

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

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>$mapEntry.key</name> <value>$mapEntry.value</value> #end In other words, use either a property, like mapEntry.key, or the method, like mapEntry.getKey().

Handlebars Template rendering template as text

I assume that unescaping in Handlebars works the same as in vanilla Mustache. In that case use triple mustaches to unescape html, i,e: {{{unescapedhtml}}}, like: <script id=”quiz-result” type=”text/x-handlebars-template”> {{#each rounds}} {{{round_end_result}}} {{/each}} <div class=”clear”></div> for ref see: http://mustache.github.com/mustache.5.html

What is the fastest template system for Python?

Here are the results of the popular template engines for rendering a 10×1000 HTML table. Python 2.6.2 on a 3GHz Intel Core 2 Kid template 696.89 ms Kid template + cElementTree 649.88 ms Genshi template + tag builder 431.01 ms Genshi tag builder 389.39 ms Django template 352.68 ms Genshi template 266.35 ms ElementTree 180.06 … Read more

advanced string formatting vs template strings

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 … Read more