Templates

Templates mean a lot of things. This time, it’s building up strings within the Fabulator engine instead of building strings in the client presentation.

I’ve not checked them into Github yet, but I’ve coded a fifth type of function definition in Fabulator libraries: the template type. They work like this:

Then, when called as, for example, m:tmpl('Foo'), you get back the string:

Notice that we don’t just return the value of the last thing. We return everything. If you want to do a series of calculations before inserting something into the template, use the f:div element to open up a computational space. It will act as it would elsewhere and insert the value of the last item calculated.

Templates don’t do any magical transformation of XML prefixes. They simply pass them along if they aren’t mapped to anything understood by the Fabulator engine.

We’re working on adding a couple of actions to the Radiant extension that will allow us to create and update pages in the CMS. The template function lets us gather information in a web form and create the page part content without embedding the page template in the program. Instead, we can factor it out into a project-specific library.

Another post when the CMS actions are finished.

Published by

James

James is a software developer and self-published author. He received his B.S. in Math and Physics and his M.A. in English from Texas A&M University. After spending almost two decades in academia, he now works in the Washington, DC, start up world.