Tagfiles are a more powerful version of a standard template. Most users will find that tag files contain all the functionality they need.
Basic tagfiles just work as templates. You can drop a file into the taglib's template directory and it will be found automatically. If your taglib classname is SimpleTaglib then your template directory will be:
HTML_Template_Nest_View::$VIEW_DIR . "/templates/simpletaglib/"
If we want to explicitly add a tag file (for example to override tag methods or add declared attributtes), we need to extend the tag file class and specify the path to the tag file's template.
Now we'll create the template in the same directory as our SimpleView.php file.
Now we'll edit our original template to use our new tag library:
Which gives us basically the same output as before, but this time it's wrapped in a div. Rather than hard code that information, however we can put the tag <nst:processBody /> into our template and then move the actual text back out of the tag file. This is where the nesting actually comes into play.
We get basicaly the same output, but now we can easily change the actual text if requirements change without changing the actual document structure. Tags can be nested and you can include tag libraries in tag files. If we wanted to add the standard tag library in our simple_tagfile.tmpl we'd do so like this:
class SimpleTaglib_SimpleTagFile extends HTML_Template_Nest_TagFile { protected $declaredAttributes = array("param1", "param2"); ... }You can then access ${param1} and ${param2} inside the tag.
That's it for tag files. They'll work in pretty much every simple situation.