My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
Features  
Notable features of JSON Template
Updated Dec 5, 2009 by andyc...@gmail.com
  • Simple and readable syntax. Template files are easily editable by non-programmers and people who won't know the language.
  • No need to learn another procedural language. Use your programming language for logic, and JSON Template for strings.
  • Extensible with your own application-specific "formatters".
  • Comes with a default set of "formatters", so it's easy to get escaping/security right.
  • Generates any kind of textual content -- readably. (A small amount of customizable syntax is allowed.)
  • Secure -- you may allow users to upload templates without compromising your application. Many template languages use eval() to embed code, which makes this usage unsafe.
  • Has a well-defined, declarative, "data-oriented" API. It uses JSON as the data model.
  • Has well-documented patterns for template reuse.
  • The syntax is an "upgrade" of Python 3 syntax. Often I use Python's string formatting for simple web apps, since it offers simple named variable substitution. If you set format_char=':', then the syntax resembles Python 3 advanced string formatting, and you get a more powerful language with very little overhead.
  • It's designed to be easily implemented, and this has paid off with multiple user-contributed implementations in different languages. Tokenization, parsing, compilation, and template expansion are all cleanly separated in the code.
  • A small implementation means you can use it in multiple contexts: at "build" time to generate static content, at runtime on the server, or on the client side (in JavaScript). This is a library, not a framework.
  • Templates can be checked for validity statically -- that is, without an accompanying data dictionary. For example, you could use this to create an SCM trigger to prevent invalid templates from being submitted. See the CompileTemplate function in the Python implementation.
  • Easy to write ad hoc tools like search/replace tools, checks for correctness and style, a syntax highlighter, maybe template security tools (for escaping), etc.
  • [Python implementation] It's Unicode agnostic. You get correct Unicode behavior depending on the types of the inputs you pass in.
Comment by amad...@gmail.com, Mar 30, 2009

Thanks for this. Curious what the differences would be between json-template and an implementation of TrimPath?'s JavaScriptTemplate??

http://code.google.com/p/trimpath/wiki/JavaScriptTemplates

Comment by project member gtempacc...@yahoo.com, Mar 31, 2009

I don't have any experience with JST, but from a quick glance it actually looks fairly similar. The main difference I see is that they're mostly focused on client-side JavaScript? templating, where as JSON Template is a language-independent library that's usable on the client or server. For example, they have no Python implementation.

They also have a less declarative syntax.

Comment by fernando...@gmail.com, Jun 12, 2009

Do you guys know where can I find any manual/documentation/tutorial to see which all the features of json-template are ?

Thanks in advance.

Powered by Google Project Hosting