todo_list_items.map(&:name)
DEBUG: SELECT * FROM ogtodolistitem WHERE todo_list_oid = 1
=> ["Make Og work with ActiveSupport's Dependencies",
"Autoload Orderable so that Ruby can find it"]
282 | Chapter 9: Incorporating and Extending Rails
Alternative Template Engines
The standard Rails template engine uses Ruby??™s ERb (embedded Ruby), which is a
very powerful template system. However, it may be too powerful for some applications.
The PHP-like free embedding of code within views can encourage placing too
much logic in a view, which the MVC architecture frowns upon. Writing HTML
code through ERb can be a painful process, as the developer must switch back and
forth between thinking in HTML and thinking in Ruby.
There are some other options on the continua of power and uniformity, and Rails
has a flexible extension system that allows different handlers to be simply registered
for different view file types. We will look at three markup languages, available as
Rails plugins: Markaby, Liquid, and Haml.
Markaby
Markaby (http://redhanded.hobix.com/inspect/markabyForRails.html) is a markup
language for HTML, by why the lucky stiff (Rails plugin due to Tim Fletcher). Its
advantage is that it is pure Ruby. All tags have a corresponding Ruby method, similar
to Ruby??™s Builder library. The markup looks like this:
h1 'Users'
ul do
@users.each do |user|
li do
user.name
link_to 'edit', user.
Pages:
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429