Skip to content

Instantly share code, notes, and snippets.

@paularmstrong
Last active January 4, 2016 00:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paularmstrong/8544180 to your computer and use it in GitHub Desktop.
Save paularmstrong/8544180 to your computer and use it in GitHub Desktop.

Non-HTML:

$ ./bin/swig.js render ./test1 -j ./data.json
onclick="pictureInsert(1, foo)"

HTML:

$ ./bin/swig.js render ./test2 -j ./data.json
<a href="javascript:void(0)" onclick=&quot;pictureInsert(1, foo)&quot;>
{ "row": { "u": 1, "url": "foo"}, "type": "u" }
{%- if type == 'url' -%}
{% set onclk = ' onclick="photoInsert('+row.u+')"' %}
{%- elseif type == 'u' -%}
{% set onclk = ' onclick="pictureInsert('+row.u+', '+row.url+')"' %}
{%- else -%}
{% set onclk = '' %}
{%- endif -%}
{{ onclk }}
{% if type == 'url' %}
{% set onclk = ' onclick="photoInsert('+row.u+')"' %}
{% elseif type == 'u' %}
{% set onclk = ' onclick="pictureInsert('+row.u+', '+row.url+')"' %}
{% else %}
{% set onclk = '' %}
{% endif %}
<a href="javascript:void(0)"{{ onclk }}>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment