<nephtali>

A simple, flexible, fast, and security-focused PHP framework
Nephtali documentation

Markup

Learn about pipes, views, optblocks, data regions, and placeholders.

Example markup

<div id="products">
<!--pipe:products-->
   <!--view:default-->
   <ul>
      <!--data-->
      <li>
         <h3 id="product{id}">
            <a href="inf.php?id={id}">
               {title}
            </a>
         </h3>
         <ul id="specs{id|attr}">
            <li>Size: {size|html}</li>
            <li>Price: {price|html}<li>
            <!--optblock:rating-->
            <li>Rating: {rating|html}</li>
            <!--optblock:rating-->
            <li>
               <a href="inf.php?id={id|url}">
                  Learn more…
               </a>
            </li>
         </ul>
      </li>
      <!--data-->
   </ul>
   <!--view:default-->
   <!--view:empty-->
   <!--view:empty-->
   <p>There are no products.</p>
   <!--view:error-->
   <p>There has been an error.</p>
   <!--view:error-->
<!--pipe:products-->
</div>
blog comments powered by Disqus

Nephtali markup types

  • <!--pipe:name-->

    Pipe comments delineate sections of markup that are dynamically controlled by Nephtali. Pipes contain one or more views, and pipes can be nested within other pipes (rendering works from the outside in.)

    In the example the products pipe is placed within a div and contains three possible views.

  • <!--view:name-->

    View comments delineate sections of markup that represent possible display states for a pipe. The 'default' and 'empty' view names are conventions for simple display pipes, and the 'error' view is required in every pipe.

    In the example the products pipe contains three views:

    default
    Displayed when there are products.
    empty
    Displayed when there are no products.
    error
    Displayed when an error has occurred somewhere in the processing of the pipe.
  • <!--optblock:name-->

    Optblock comments delineate sections of markup that are conditionally displayed depending on the the particular values being databound.

    In the example the ratings optblock is only shown if there are ratings present for the production being rendered.

    You can view example PHP code for optblocks in the API documentation under the n\view\render() function.

  • <!--data-->

    Data comments delineate sections of markup within views that should be databound. Markup within a set of data comments is repeated for every row that is databound.

    In the example the default view contains a data region that would repeat for every product listed.

  • {name}

    Placeholders map values within the rows databound to the markup by their respective keys. There are two forms of placeholders:

    {name}
    The value is automatically escaped appropriately depending on context (url encoding, attribute encoding, or html encoding with allowed whitelists.)
    {name|escaping}
    Values are escaped according to the escaping option explicitly provided in the placeholder. Possible options include:
    • html
    • attr
    • url