Child pages
  • [template parser] Template parser compiled template format change
Skip to end of metadata
Go to start of metadata

Imported From: http://groups.google.com/group/in-portal-dev/browse_thread/thread/3a1669af92586ba1#

I've recently looked at how Twig stores it's compiled templates and I liked it. It simply creates unique class name and wraps all template contents into it.

Usual template consists of 2 things (both optional):

  • element definitions - creates a function that can be used later, but doesn't produce any output at place, where it's defined
  • tags that output something

Because right now we don't use class to wrap functions we create some crazy hashes based on template_path+element_location+element_name

When wrapped in a class we can improve several things:

  1. only 1 weird hash per file (in class name)
  2. functions, created as a result of template compilation not accessible in global scope (no need to exclude whole /system/cache folder, just to make auto-complete more intelligent)
  3. methods in compiled templates match exact element names in that template, so searching for a compiled method representation is easy (if you need to debug it or something)
  4. mapping between block names and their implementation points are easier to understand (e.g. if you have an element with same name locally in some template, then you'll see in which one exactly)

1 Comment

  1. This is quite interesting. In face it might be some other improvements that we can implement to the parser if we look around. I bet you since the time you looked and now there might be more "low hanging fruits" that we can take.