I was talking with a co-worker today at lunch, and found this nice use
case.  This is extremely annoying for our tech-writers:

<pre>
  if (n &lt; 3 &amp;&amp; m &gt; 3) {
    var s = "foo";
  }
</pre>

The problem is escaping <>& in code, especially when having to go back
and edit it.  It's very error prone.  A very nice use of formatters
is:

{.section snippet|html}
  if (n < 3 && m > 3) {
     var s = {s|js-string};  # I can also format a javascript string
here, and THEN escape it as HTML too!
  }
{.end}


Here is another very nice use from my documentation:

{.section template|json-template-code}  # syntax highlight as JSON Template
{.end}

{.section data-dictionary|json}  # syntax highlight JSON dict
{.end}

{.section result|html}  # syntax highlight the expanded result as HTML
{.end}

I use this all in the same doc.  If you look at the scheme I use to
generate my docs docs, it's actually a bit awkward now:

http://code.google.com/p/json-template/source/browse/#svn/trunk/doc


Generate a graph image inside an HTML doc:

[.section graph|dot-format]
  digraph {
     ...
     [variables] [here] [too]  # expansion occurs before dot-format
  }
[.end]

The formatter could render the .dot file as an image graph, and then
return an <img src="rendered.png">.

I have seen people do this type of thing with Javascript (including
google-code-prettify, which is used on code.google.com).  However,
it's a lot faster to render if it's done on the server side (and
cacheable, etc.).

Currently, you could do this with a static JSON file, but this is annoying:

{"data-dictionary": "{\"name\": \"value\"}"
  "template": "..."
  "result": "<a href=\"...\"",
}

So I think this feature is quite simple to implement, general, and
consistent with the rest of JSON Template.  Also, I don't think other
template engines solve this problem.  This would be a really nice
feature which would make JSON Template stand out in the (large) crowd.
 People generally evaluate technologies by features, and unfortunately
minimalism is not considered a feature.  Especially if there was an
add-on library of all these formatters, I could see it becoming quite
popular.

Andy

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JSON 
Template" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/json-template?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to