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 Haml #10

Closed ghost closed 9 years ago

ghost commented 10 years ago

What is Haml? Why and how is it used? Does it have any dependencies we should know about? How is Haml currently supported, in terms of syntax highlighting or other features, in Sublime Text 3?

picchietti commented 9 years ago

[DOCUMENTATION]

What is Haml/Why use it: An alternative to rails templating language (.erb files), Haml generates page markup (html) in a compact and efficient manner. Ruby code is often used to assist in the generating process.

How to use it: Haml is used with Ruby through its RubyGem. RubyGem is a package manager (like apt-get, etc) for installing ruby programs and libraries. Haml can be used via command line to output html files.

$ gem install haml;
$ haml input.haml output.html;
Basic syntax introduction:
/ comment line, indent for multi-line comment
-# silent comment that isn't added to output.
%tag - denotes a <tag>. Indents denote ownership instead of opening/closing tags. div is the default tag.
%tag text - Add content to a tag, for example: <tag>text</tag>. Same indenting rules apply.
%tag#identifier - Add an id to a tag, example: <tag id="identifier" />
%tag.class1.class2 - Individually or chain add classes to tags such as <tag class="class1 class2">
%tag{:attribute => 'value', :attribute2 => 'value'} - Add attributes to tags. <tag attribute="value" attribute2="value" />
%tag= ruby.variable - Add the content of a ruby variable as the content of a tag. <tag><?php echo $var; ?></tag>
- (hyphen), when prepended to ruby code, will run ruby code, but NOT add it to the generated markup.

Other tasks such as escaping, unescaping, filters, etc. are not covered above.

Dependencies: Ruby.

Haml support in Sublime T3: The official Haml website mentions Sublime T2 specifically, but Sublime T3 is supported too.

  1. In Sublime T3, go to file > new file
  2. In the bottom right-hand corner (status bar), click 'plain text'
  3. Select Rails > Ruby Haml