user3824766
user3824766

Reputation: 1

How to substitute curly braces in JavaScript?

I'm struggling embedding some code in ktools Photostore. The only thing we try is to create a site including a wufoo form which results in an error.

User support responded to me:

Content input in to the editor cannot use the characters { or }. These are reserved for the Smarty Template Engine.

So my questions is: how to parse this code to embed my form?

The Code:

var xyz;
(function (d, t) {
  var s = d.createElement(t),
    options = {
      'userName': 'abc',
      'formHash': 'xyz',
      'autoResize': true,
      'height': '400',
      'async': true,
      'host': 'wufoo.com',
      'header': 'show',
      'ssl': true
    };
  s.src = ('https:' == d.location.protocol ? 'https://' : 'http://') + 'www.wufoo.com/scripts/embed/form.js';
  s.onload = s.onreadystatechange = function () {
    var rs = this.readyState;
    if (rs) if (rs != 'complete') if (rs != 'loaded') return;
    try {
      xyz = new WufooForm();
      zyx.initialize(options);
      xyz.display();
    } catch (e) {
    }
  };
  var scr = d.getElementsByTagName(t)[0],
    par = scr.parentNode;
  par.insertBefore(s, scr);
})(document, 'script');

Upvotes: 0

Views: 222

Answers (1)

epascarello
epascarello

Reputation: 207527

It is right in the documentation

In Smarty templates, the { and } braces will be ignored so long as they are surrounded by white space. This behavior can be disabled by setting the Smarty class variable $auto_literal to false.

or

{literal}..{/literal} blocks are used for escaping blocks of template logic. You can also escape the braces individually with {ldelim},{rdelim} tags or {$smarty.ldelim},{$smarty.rdelim} variables.

Upvotes: 2

Related Questions