Dummy - The Framework for Dummies! - The View

The Template engine (View, the .HTML file) of the Dummy is basically a copy&paste of my previous engines used in my several work frameworks I perfected over the years. It is simple enough that it fits the Dummy approach, while having some very neat characteristics and features.

There are two types of tags within the View: simple tags, like {title}, and content tags that enclose text, like {_title}Content{/title}. Simple tags can be simply assigned or read, working mostly as variables within the template. Content tags are extra useful because they already contain data when you start, and you can read them as another instance of a view and work with it in, for instance, a loop. You can also totally remove them conditionaly, like removing every {_mobileonly} contents if you are running the page on a desktop.

You can nest tags inside content tags any way you want, meaning, you can have tags inside of tags.

The Framework uses some pre-defined tags to automatically fill common data, like {PAGE_LANG}, {PAGE_TITLE}, {PATH_FILES}, {DOMAIN_NAME}, {_ajaxonly}, {_removeonpopup}, {_removeonajax}, {_removemob} or {_mobonly}

The Template engine will also automatically create some tags on specific parts of the HTML, like {AUTOBODY} (comes after the </body>, useful to add late scripts) and {AUTOHEAD} (comes before </head>, useful to add meta and scripts inside the head).

The most important functions from the View object are ->assign($tag,$content), which will assign the output value of a variable (be it simple or content), ->get($tag), which will return the contents of a content tag (might return a View object if the content also have tags, or a string if not), ->append($content,$into) to append content in a specific tag, and ->assignFile($tag,$file) to assign the contents of a file into a tag.

Furthermore, you can add formatting to a tag using the "|" separator. For instance, {tag|number} will format the content of "tag" as a number, or {tag|truncate|50} will truncate the tag in at most 50 characters.

To see all functions and format definitions, check the full View reference guide.

 

◀ Back

Ads by google:
Important Notice