About this book

This book contains every handlebars features and example, you can find working example code for both handlebars.js and lightncandy

What is...

mustache

Mustache is a logic-less template syntax. It can be used for HTML, config files, source code - anything. It works by expanding tags in a template using values provided in a hash or object.

handlebars.js

Handlebars.js is an extension to the Mustache templating language created by Chris Wanstrath.

lightncandy

LightnCandy is an extremely fast PHP implementation of handlebars and mustache.

How mustache/handlebars works...

template

My name is {{name}} and I am {{age}} years old.

+ data

{
  "name": "John",
  "age": 18
}

= result

My name is John and I am 18 years old.

Keyboard Shortcuts

You may use keyboard to navigate this book fast:

When the drop down menu is displayed, you can:

Legend

Codes

codes

Correct/Expected

Sample output

Different

Different output

Error/Unexpected

Error output

Partials List

partial_namepartial template
partial_name2partial template...

Options

Option1 Option2

Versions

Table of Content

  1. About this book
  2. Create your project
  3. Hello World
  4. Simple Variable
  5. Variable Escaping
  6. Raw Output
  7. Specific Values
  8. Block
  9. Inverted Block
  10. Comment
  11. Partials
  12. Set Delimiter
  13. Dot Notation
  14. Handlebars: Path
  15. Handlebars: Extended Comment
  16. Handlebars: Built-in block helper - #if
  17. Handlebars: Built-in block helper - #unless
  18. Handlebars: Built-in block helper - #with
  19. Handlebars: Built-in block helper - #each
  20. Handlebars: Built-in helper - lookup
  21. Handlebars: Custom Helper
  22. Handlebars: Block Custom Helper
  23. Handlebars: Named Arguments
  24. Handlebars: Change Partial Context
  25. Handlebars: Parent Context
  26. Handlebars: Subexpression
  27. Handlebars: Advanced Variable
  28. Handlebars: Dynamic Partial
  29. Handlebars: Use SafeString
  30. Handlebars: Change Context
  31. LightnCandy: Quick Start
  32. LightnCandy: Custom Helper
  33. LightnCandy: The $options Object
  34. LightnCandy: Use SafeString
  35. LightnCandy: Deep Dive Partials
  36. LightnCandy options
  37. LightnCandy option: helperresolver
  38. LightnCandy option: partialresolver
  39. LightnCandy option: safestring
  40. LightnCandy option: FLAG_ADVARNAME
  41. LightnCandy option: FLAG_BESTPERFORMANCE
  42. LightnCandy option: FLAG_ECHO
  43. LightnCandy option: FLAG_ELSE
  44. LightnCandy option: FLAG_ERROR_EXCEPTION
  45. LightnCandy option: FLAG_ERROR_LOG
  46. LightnCandy option: FLAG_ERROR_SKIPPARTIAL
  47. LightnCandy option: FLAG_EXTHELPER
  48. LightnCandy option: FLAG_HBESCAPE
  49. LightnCandy option: FLAG_INSTANCE
  50. LightnCandy option: FLAG_JS
  51. LightnCandy option: FLAG_JSLENGTH
  52. LightnCandy option: FLAG_JSOBJECT
  53. LightnCandy option: FLAG_JSTRUE
  54. LightnCandy option: FLAG_METHOD
  55. LightnCandy option: FLAG_NAMEDARG
  56. LightnCandy option: FLAG_NOESCAPE
  57. LightnCandy option: FLAG_PARENT
  58. LightnCandy option: FLAG_PARTIALNEWCONTEXT
  59. LightnCandy option: FLAG_PROPERTY
  60. LightnCandy option: FLAG_RUNTIMEPARTIAL
  61. LightnCandy option: FLAG_SLASH
  62. LightnCandy option: FLAG_STANDALONEPHP
  63. LightnCandy option: FLAG_THIS