03/02 2013
VHS 1.5.0 released

This new version contains the brand new Asset feature as well as a handful of new, useful ViewHelpers such as the Menu / Directory and List ViewHelpers and Video/Media objects as well as a DomainObject and DateTime compatible JSON encode and decode set of ViewHelpers.

Dear developers

Once again here are some good news. The Assets feature in VHS has been completed - and if you don't already know what it is, I suggest you read the Asset Management in Fluid article. Briefly described the Asset feature allows unprecedented control over Asset inclusions (CSS, JS, etc.) at the same time as allowing the inclusion to take place inside Fluid templates - of absolutely any kind (as long as it is rendered in the frontend, naturally).

The feature is tremendously easy to use:

<v:asset name="jquery" path="//some.com/cdn/url/jquery.js" />
<v:asset name="my-jquery-script" dependencies="jquery" path="path/to/script.js" />

And because it does not matter in which sequence the inclusions are performed, you can just as easily reverse the two lines - or place one in the Layout and another in a Partial template. Not only that - when enabled, even standalone Assets can be initially parsed using Fluid, with custom template variables assigned. The most recent version of fluidpages_bootstrap demonstrates this (and indeed, you can see the effect on this web site: the jumbotron display has colors, sizes and margins configurable in the page properties but use an external CSS file with Fluid variable markers as a template to create new, unique stylesheets. However, only one stylesheet is created per unique configuration of parameters so inherited template variables (see other news item about Fluid Pages being updated) do not create duplicated CSS files.

The new JSON encoding ViewHelper not only supports objects which usually would break JSON (DateTime, objects with getters/setters and protected/private properties) - it also supports DomainObjects and supports them recursively without breaking. It even has an option to place a fake object at locations where recursion occurs. A practical use case example which combines the power of VHS Assets and this JSON encoding ViewHelper (this is where things get interesting!):

<v:asset.script name="json-news">
    var newsList = {newsitems -> v:format.json.encode()};
</v:asset.script>
<v:asset.script name="uses-news-json" dependencies="json-news">
    alert('There are ' + newsList.length + ' news items in the list');
</v:asset.script>

The JSON representation is then stored in a separate file - it is even merged with the script chunk which uses it (because the standalone flag was not set). Like with every other Asset you can place the JSON encoded representation after the script chunk which uses it - the order doesn't matter as long as you use dependencies. Imagine having to create that manually... never again. And since Assets are connected to the caches: clearing the cache also rebuilds the Asset (indeed every Asset) from scratch.

That's about it. I certainly hope you enjoy using it as much as I enjoyed creating it. I know I will find it extremely handy in the future!

Cheers,
Claus