x

Main chapters

  1. LimeSurvey Cloud vs LimeSurvey CE
  2. LimeSurvey Cloud - Quick start guide
  3. LimeSurvey CE - Installation
  4. How to design a good survey (Guide)
  5. Getting started
  6. LimeSurvey configuration
  7. Introduction - Surveys
  8. View survey settings
  9. View survey menu
  10. View survey structure
  11. Introduction - Questions
  12. Introduction - Question Groups
  13. Introduction - Surveys - Management
  14. Survey toolbar options
  15. Multilingual survey
  16. Quick start guide - ExpressionScript
  17. Advanced features
  18. General FAQ
  19. Troubleshooting
  20. Workarounds
  21. License
  22. Version change log
  23. Plugins - Advanced
 Actions

Template engine

From LimeSurvey Manual

Revision as of 09:11, 15 September 2016 by Olle (talk | contribs) (Security)

Since Louis factored out all HTML from qanda and added a configuration file to the templates, it's a small task to add a template engine, replace the PHP views with e.g. Twig templates.

Use-case

  • Template providers don't have to worry about core changes in the question view files
  • Template providers can apply any CSS framework specific HTML they want, like Foundation

Requirements

Must have

  • Template files in template zip packages can override question view files
  • Template zip package can upload template files in template editor

Should have

  • Possible to edit Twig/Mustache templates in template editor

Could have

?

Comparison between Twig and Mustache

Function Twig Mustache
Echo variable {{var}} {{var}}
Echo field in variable {{var.field}}, {{var['field']}} {{#var}} {{field}} {{/var}}
Loop variable {% for user in users %} ... {% endfor %} {{#users}} ... {{/users}}
Branch on boolean {% if trueOrFalse %} ... {% endif %} {{#trueOfFalse}} ... {{/trueOrFalse}}
Translate Bind eT to lambda and then {{#eT}} "String to translate"" {{/eT}}
Sandbox Yes Not needed

Security

Longer article about template injection: http://blog.portswigger.net/2015/08/server-side-template-injection.html

The lowest risk approach is to simply use a trivial template engine such as Mustache

About CPU load: It wold be easy for a template designer to make a loop within a loop within a loop etc, to exhaust the CPU power of the server. This vulnerability is in all template engines where you can loop an array (Mustache, Twig). To protect against this, the server should have a max script runtime set.

BUT: Rendering PDF takes a long time, how to know the right limit?