greplytix / Hamlbars

Sublime Text 3 Syntax highlighting for .hamlbars files which is a combination of both Haml and Handlebars
MIT License
2 stars 0 forks source link

Research Handlebars #11

Closed ghost closed 9 years ago

ghost commented 9 years ago

What is Handlebars? Why and how is it used? What are its dependencies, if any? What is the current support for it in Sublime Text 3, if any? Can we leverage existing support for our project?

anthonykulis commented 9 years ago

@abandimh01 Hey, been 22 days? what is happening with this?

anthonykulis commented 9 years ago

@abandimh01 @reesington So, I asked a question on this 8 days ago about something that was opened 22 days ago. Can we please get on this.

ghost commented 9 years ago

[DOCUMENTATION]

Handlebars

Introduction

Handlebars is a client-side JavaScript templating engine. In general, JavaScript templating engines are used when loading lots of complex, list-organized data from servers so as to leverage memory and processing on clients' machines. Handlebars templates may be included via a simple <script> tag in HTML. These templates may be easily precompiled for runtime efficiency. Handlebars expressions are entered by {{ and exited by }}. Escaping these expressions just requires an extra bracket for entry and exit.

How Handlebars Is Used in Further Depth

Paths

Handlebars also supports paths so that something like the following may be used to refer to nested JavaScript object properties: {{object.property}}. Paths support ../ as referring to a parent in a given context. Even the this keyword is supported in resolving naming conflicts.

Comments

Handlebars commenting is accomplished by {{!-- --}} or {{! }}. One should not use the latter form if embedding Handlebars tokens (or any kind of double curly brackets) inside the comment. Both types of commenting are not visible in resulting output.

Block Expressions

Block expressions allow you to define helpers that will invoke a section of your template with a different context than the current.

Thus, a block expression would typically look something like this: {{#list object}} {{firstProperty}} {{secondProperty}} {{/list}}, where list refers to a JavaScript function designed to create a list of JSON objects by accessing their firstProperty and secondProperty. Please see this page for more details -- it also covers helper registration and existing helpers.

Dependencies

Handlebars simply requires a browser capable of parsing its JavaScript library.

Existing Support in Sublime Text 3

This project, open source on GitHub with steady support and contributions, seems to do most of our job for us. It supports syntax highlighting and tab triggers. It's also available via Package Control. We should scrutinize this project to see if it's eligible for us to leverage. Its general layout may aid in extending Sublime Text 3 support for Haml.