Skip to content

MajorLeagueBaseball/freemarker-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Freemarker JSON Macro

This macro takes a Freemarker model and prints it out as JSON. Output is compressed to a single line.

Usage

<#import "json.ftl" as json>

<@json.stringify your_model_here />

Escaping

Escape the generated JSON with the second argument to <@json.stringify>. The options are html and js_string.

<meta name="extraData" content='<@json.stringify extra_data "html" />' />

<script type="text/javascript">

var myExtraJSON = '<@json.stringify extra_data "js_string" />';

// of course, if you need the data, not a JSON string, you can do this:
var myExtraData = <@json.stringify extra_data />;

</script>

About

A Freemarker macro for outputting JSON.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published