Play!Framework – Custom Template Tags and Namespaces

I have been playing with Play!Framework recently (I will hopefully write more about this in the future), but the documentation is horrible!

I was interested in seeing if there was a better way to organise custom HTML template tags in the tags folder, in order to prevent any clashes in my templates. Non of the documentation explicitly explains how to do so; the only references as such only refer to writing custom Tags in Java and annotating with @FastTags.Namespace.

On a hunch, however, I tried creating a child folder in my Tags folder, and treated that as a namespace (as in Java) and it worked! For example:

1
#{admin.widget /}

would look for the HTML Template Tag as

1
/app/views/tags/admin/section.html

or

1
/app/views/tags/admin/section.tag

Hopefully this helps someone else who comes across this requirement in their project. Note that this might have side-effects that I am unaware of (other than clashes with existing template tags, or custom Java tags). As far as I’m aware, this is an unsupported feature of the template engine, so use at your own risk I suppose.

Learning C#: Early Impressions

For the last couple of weeks, I have been spending time learning C# (the mongrel offspring of Java and C++, as I like to describe it). So far, I haven’t had much trouble, thanks to my strong background in Java, and I think I have done enough in a week to be able to compare the two languages and talk about the parts I like and the parts I don’t. Perhaps these will grow on me in the future, or it may not.

This is not a rant about ASP.NET, which I have also been learning at the same time. That will come in time. Continue reading