Run template functions based on data attributes #20

Closed
opened 2021-06-02 17:42:03 +02:00 by FWDekker · 0 comments
Owner

Instead of relying on pages that use the template to run header() and similar functions, the template should run those functions based on the data embedded in, say, the meta tags or based on data attributes attached to the body. For example, using meta tags, the page using the template could include

<meta name="fwd:nav:name" value="/Tools/" />
<meta name="fwd:header:title" value="Tools" />
<meta name="fwd:header:description" value="An overview of tools I have created" />
<meta name="fwd:footer:vscURL" value="https://git.fwdekker.com/FWDekker/tools/" />
<meta name="fwd:footer:version" value="v1.4.2" />

Maybe some tags (such as fwd:header:description) are not necessary since there is also the description meta tag already. (But maybe I'll just keep the duplicate tag.)

Not including the tag means that undefined is passed to the function. Not including the value attribute in the tag means null is passed to the function. Using value="" means that the empty string is passed to the function.

Not including any fwd:footer:* tags at all means that the template will not run its footer function. To run footer with all undefined values, the tag fwd:footer should be added without the value attribute.


The advantage of this method is that pages such as the error pages do not need to include and compile scripts, which simplifies the page.

Instead of relying on pages that use the template to run `header()` and similar functions, the template should run those functions based on the data embedded in, say, the meta tags or based on data attributes attached to the `body`. For example, using meta tags, the page using the template could include ```html <meta name="fwd:nav:name" value="/Tools/" /> <meta name="fwd:header:title" value="Tools" /> <meta name="fwd:header:description" value="An overview of tools I have created" /> <meta name="fwd:footer:vscURL" value="https://git.fwdekker.com/FWDekker/tools/" /> <meta name="fwd:footer:version" value="v1.4.2" /> ``` Maybe some tags (such as `fwd:header:description`) are not necessary since there is also the `description` meta tag already. (But maybe I'll just keep the duplicate tag.) Not including the tag means that `undefined` is passed to the function. Not including the `value` attribute in the tag means `null` is passed to the function. Using `value=""` means that the empty string is passed to the function. Not including any `fwd:footer:*` tags at all means that the template will not run its `footer` function. To run `footer` with all `undefined` values, the tag `fwd:footer` should be added without the value attribute. --- The advantage of this method is that pages such as the error pages do not need to include and compile scripts, which simplifies the page.
FWDekker added the
feature
label 2021-06-02 17:42:03 +02:00
FWDekker self-assigned this 2021-06-02 17:42:03 +02:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: fwdekker.com/template#20
No description provided.