Interfaces

Project

Pages Html

NuGet packageOwin.Framework.Pages.Html
GitHub sourceOwinFramework.Pages.Html

Home |  Readme

Multi-part parser reference | The OWIN FRamework

The Multi-part template parser

The Multi-Part template parser creates multi-part templates by allowing you to combine multiple templates into one file, then rendering those templates into different parts of the page at runtime.

For example the following template:

--head
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
--init
$("p").hide();

When added to a page will cause all of the paragraphs in the page to be hidden. This works because the line that references jQuery will be rendered into the page head, and the part after --init will be written into the initialization script at the bottom of the page after all of the Html.

Section Dividers

The sections of the multi-part template are separated by special dividers that comprise two hyphens and a word that identifies the area of the page to render into. These dividers are:

  • --head identifies html to render directly into the page head
  • --css identifies css style definitions to render into the page head
  • --javascript identifies Javascript functions to render into the page head
  • --html identifies html to render into the body of the page
  • --init identifies Javascript statements render into a script block at the bottom of the page after all of the Html
Note that the CSS styles should not be wrapped in a <style> tag, and Javascript functions should not be wrapped in a <script> tag. All of the styles and functions are gathered up together and wrapped appropriately.