Guest User

Untitled

a guest
Jul 21st, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. tests:
  2. - name: Interpolation
  3. desc: A lambda's return value should be interpolated.
  4. data:
  5. lambda: !code
  6. js: 'function() { return "world" }'
  7. template: "Hello, {{lambda}}!"
  8. expected: "Hello, world!"
  9.  
  10. - name: Interpolation - Expansion
  11. desc: A lambda's return value should not be parsed.
  12. data:
  13. planet: "world"
  14. lambda: !code
  15. js: 'function() { return "{{planet}}" }'
  16. template: "Hello, {{lambda}}!"
  17. expected: "Hello, {{planet}}!"
  18.  
  19. - name: Escaping
  20. desc: Lambda results should be appropriately escaped.
  21. data:
  22. lambda: !code
  23. js: 'function() { return ">" }'
  24. template: "<{{lambda}}{{{lambda}}}"
  25. expected: "<>>"
  26.  
  27. - name: Section
  28. desc: Lambdas used for sections should receive the section block.
  29. data:
  30. x: 'foo'
  31. lambda: !code
  32. js: 'function(block) { return (block() == "foo" ? "yes" : "no") }'
  33. template: "<{{#lambda}}{{x}}{{/lambda}}>"
  34. expected: "<yes>"
  35.  
  36. - name: Section - Expansion
  37. desc: Lambdas used for sections should not have their results parsed.
  38. data:
  39. planet: "Earth"
  40. lambda: !code
  41. js: 'function(block) { return block() + "{{planet}}" + block() }'
  42. template: "<{{#lambda}}-{{/lambda}}>"
  43. expected: "<-{{planet}}->"
  44.  
  45. - name: Section - Multiple Calls
  46. desc: Lambdas used for sections should not simply cache the first response.
  47. data:
  48. lambda: !code
  49. js: 'function(block) { return "__" + block() + "__" }'
  50. template: '{{#lambda}}FILE{{/lambda}} != {{#lambda}}LINE{{/lambda}}'
  51. expected: '__FILE__ != __LINE__'
  52.  
  53. - name: Inverted Section
  54. desc: Lambdas used for inverted sections should be considered truthy.
  55. data:
  56. static: 'static'
  57. lambda: !code
  58. js: 'function(block) { return block() }'
  59. template: "<{{^lambda}}{{static}}{{/lambda}}>"
  60. expected: "<>"
Add Comment
Please, Sign In to add comment