Nested templates in fragment.js

Verified to work with existing samples. Could use some slightly cleaning of the code.

This is a redo of issue #14.