The plugin registers a template handler for all
view files with an extension of .liquid. You can mix and match your Liquid views
with standard Rails views, and the Liquid views get all of the assigned instance variables
from the controller. The following is an example of Liquid code:
Users
{% for user in users %}
- {{ user.name }} ({{ 'edit' | link_to: user.edit_url }})
{% endfor %}
Haml
Haml is a very terse markup language designed to concisely represent HTML. Haml
was created by Hampton Catlin and is available from http://haml.hamptoncatlin.com/.
The Haml philosophy is summarized on the tutorial page: ???Every character means
something.??? We see this in several ways in Haml:
??? There are no closing tags; indentation denotes nesting.
??? The verbose id and class attributes are shortened to their CSS equivalents # and .,
respectively.
??? The commonly used div tag can be omitted altogether.
??? Rails HTML output is expressed by a single = sign instead of ERb??™s <%= %> tags.
Haml??™s terseness can make it a bit difficult to understand at first, but many people
find it useful and less intrusive than ERb markup. Our example can be coded in
Haml as follows:
%h1 Users
%ul
- @users.each do |user|
%li
= user.name
= link_to('edit', user.edit_url)
284 | Chapter 9: Incorporating and Extending Rails
Notice that we do not need to close anything.
Pages:
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431