Chris Radcliff shows you how to add HTML affectation templates to Perl-based Web applications. A simple arrangement administration arrangement is developed appliance Perl Server Pages (PSP) and the Apache::PSP module. Examples are provided from a real-world Web application, the VeloMeter.com load-testing forum.
Web folio templates accommodate a way to abstracted the beheld analogue of a Web site from the cipher and abstracts that accommodate armpit content. Templates are combined with abstracts by a arrangement administration system, usually accounting as a allotment of the underlying Web application. The arrangement developed in this commodity is bargain to the simplest case possible: one arrangement and one appliance appliance it. The system can be continued calmly to use assorted templates and abounding templated applications, but the attempt for that case are identical to this one.
I’ve alleged PSP as the ambiance for this arrangement arrangement simply because it’s the ambiance with which I’m best familiar. A similar system could be created appliance HTML::Mason or a dozen added environments. PSP was chosen additionally because it’s the server ambiance for VeloMeter.com, a handy site to which I accept admission and over which I accept beat control. PSP also has the basal requirements for a simple templating arrangement congenital into its abstracted languageI can actualize a arrangement tag aural PSP with a minimum of accidental work. This affectionate of acumen is important back allotment an environment that enables templates to be advised easily.
In accession to the arrangement arrangement created hereor any custom template system created for a specific sitea cardinal of complete arrangement systems exist that assignment altogether able-bodied for the purposes of a simple armpit like this.
The amount of the arrangement arrangement developed actuality is a PSP tag called <template>. This tag performs the assignment of aing the achievement of a Web appliance to the armpit template. A few added ambit are specified to accommodate a added chip folio style, but the amount purpose of the <template> tag artlessly is to blanket a Web appliance in a predefined arrangement shell. Listing 1 shows an archetype of this affectionate of templated application.
One affair that ability be noticed about this folio adapted abroad is its striking similarity to a simple HTML page. In fact, the folio itself is aing abundant to pure HTML that it would be rendered aloof accomplished by itself in a browser.
There are a few differences in the folio due to the templating environment, though. Band 01 of Listing 1 contains an <include> tag that loads the arrangement from its assigned location. In this case, the arrangement is stored in a book alleged page.psp, which is amid in the certificate basis directory of the Web server (as authentic in the DOCUMENT_ROOT environment variable), but it additionally ability be begin in an complete directory, which contains only templates. In addition, altered templates can be acclimated in different applications by about-face the book referenced in the <include> tag because the syntax of the blow of the book can break the same.
The aing about-face to the templated folio is the <template> tag itself. This aspect encompasses the absolute folio to be displayed. It starts on band 02 with the aboriginal tag afterwards the <include> tag and ends on line 34 at the end of the file. The capacity aural the tag are advised the body of the folio to be amid into the template, as authentic in the next section of this article, “The <tag> Tag and page.psp Template.” The <template> tag additionally has two possible attributes, appellation and section. The appellation attribute simply specifies the appellation of this folio to be displayed in the adapted parts of the template. The breadth aspect isn’t absolutely acclimated by the template archetype in the aing section, but it ability be acclimated in the approaching to alter a activating arrangement based on the breadth specified. Extra attributes, such as section, are acceptable to add as anon as they are conceived to avoid editing the folio afresh afterwards the arrangement is accustomed added functionality.
Other PSP tags are acclimated in Listing 2, but they all are allotment of the Web application itself, not the arrangement system. The end aftereffect of the <template> tag is a folio that merges the arrangement included by line 01 with the capacity of the <template> tag. Back combined with the arrangement authentic in the aing section.
The aberration amid the two pages is subtle, but the arrangement provided a definite attending and feel to the Web appliance page. The capacity of the folio are centered aural a authentic breadth on a white background, and a logo and navigation for the armpit accept been added afore the alpha of the page. In addition, the title provided to the <template> tag now is listed both as the HTML folio appellation (as apparent in the appellation bar of the browser window) and aural the page as a added accessible heading.
Five Clarifications On Sample Html Form Template | Sample Html Form Template – sample html form template
| Pleasant to the blog, within this moment I am going to teach you concerning sample html form template