If-Statements in Templates

Martin Böhringer's Avatar

Martin Böhringer

13 Jan, 2012 04:21 PM via web

Hi there,
does your template engine support kind of if-statements? Something like if(somevalue<10) "Good job." else "You! did! great!!!"?
Thanks,
Martin

  1. Support Staff 2 Posted by Tom Walsham on 13 Jan, 2012 04:29 PM

    Tom Walsham's Avatar

    Hi Martin,

    At the moment, our templating engine does not support conditional statements from the API call. We are working on an implementation of it in the future, but none are working as of yet.

    However, in my experience, you can perform the conditional statement server-side before you make the API call, passing in the necessary content into the call itself.

    Let me know if that works for you, Martin.

  2. Support Staff 3 Posted by Tom Walsham on 13 Jan, 2012 04:50 PM

    Tom Walsham's Avatar

    Martin,

    Our awesome developer Scott just informed me that we have an undocumented method for templates and conditional content, that I am now documenting.

    Inside the template, place any conditional content between these variable tags:

    {{?variable_name}}
    Content here.
    {{/}}
    

    And when making an API call, you just have to define variable_name with any content, and it signals the template to include the content within the tags.

    variables: {
      'variable_name': 'Any content here, seriously.'
    }
    

    And of course, variable_name can be anything you want to name it.

    Hope that helps Martin!

  3. 4 Posted by Martin Böhringer on 14 Jan, 2012 11:16 AM

    Martin Böhringer's Avatar

    Hi Jon,

    This is perfect! Exactly what we need. You just got a new fan :)

    Cheers,
    Martin

  4. Support Staff 5 Posted by Tom Walsham on 16 Jan, 2012 03:05 PM

    Tom Walsham's Avatar

    Martin,

    That's exactly what we like to hear. Let us know if there is anything else we can do for you!

    Cheers.

  5. Tom Walsham closed this discussion on 16 Jan, 2012 03:05 PM.

Comments are currently closed for this discussion. You can start a new one.