Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slim: pretty and ugly

In the article, which explains difference in performance perspective of rails template engines I find slim pretty and slim ugly terms. Can you explain difference between this?

like image 691
Pavel Babin Avatar asked Mar 18 '23 18:03

Pavel Babin


2 Answers

Seems like Slim uses Temple for template compilation. Temple provides the set_default_options method to Slim::Engine, documented and explained here.

The corresponding Temple code that does the 'pretty' transformations (tab indentations and reordered attributes) to the compiled HTML appears to be here: https://github.com/judofyr/temple/blob/master/lib/temple/html/pretty.rb

I presume ugly just refers to having the pretty option set to false. The article you referenced is comparing performance, so the relevance of the pretty option to performance appears to be that the extra processing increases the overhead when generating HTML.

like image 138
Mike Campbell Avatar answered Apr 01 '23 14:04

Mike Campbell


Its just the way the resulting html is rendered:

  • pretty: indentations are clean and easy to follow, useful for development mode
  • ugly: everything is dumped without tabs, shorter (but difficult to read), ideal for production
like image 35
apneadiving Avatar answered Apr 01 '23 13:04

apneadiving