Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Rails Template Engines (Spanish)

Rails Template Engines (Spanish)

A comparison between the most popular Rails template engines: ERB, Haml & Slim. Slides are in spanish.

Avatar for Sebastián Vicencio

Sebastián Vicencio

April 29, 2015
Tweet

More Decks by Sebastián Vicencio

Other Decks in Programming

Transcript

  1. Template Engines en Rails %div#container.some_class Some text .content 
 =

    some_var_or_function_with_output - if condition
 # Some logic with indentation
 #container.some_class Some text .content 
 = some_var_or_function_with_output - if condition
 # Some logic with indentation

  2. Templates con dos modalidades: • Pretty: indenta HTML y hace

    sort de atributos • Ugly: compilación en bruto Template Engines en Rails
  3. Benchmarks • Slim: benchmark con 1.000 iteraciones. • @sephinrothcn extendió

    benchmark: • 100.000 iteraciones • Distintas versiones de Ruby • Distintas versiones de Rails
  4. Conclusiones • Slim es claramente más rápido que Haml. •

    Slim Ugly es comparable en rapidez a ERB.
  5. Conclusiones • Slim es la mejor combinación entre velocidad de

    desarrollo y performance de rendering. • Tip: usar pretty en development y ugly en production.
  6. Configuración Slim • Pretty Slim viene por defecto. • Para

    cambiar a Ugly Slim: Slim::Engine.set_options pretty: false, sort_attrs: false