public
Description: PURE Unobtrusive Rendering Engine for HTML
Home | Edit | New

pure.map method

This is the method to apply directives to an HTML

pure.map( directives, html [, noClone] )

Parameters:





directives


object


This is the commands to tell PURE how to link the JSON data and the HTML. See more information about directive at What is a directive ?


html


DOM


This is the HTML template we want to transform with the data


noClone (optional)


boolean


False:The HTML template will be untouched and a clone will be returned (default value)
True:The HTML template will be changed

Output:


html


DOM
This method returns a string with the HTML transformed. It can then be inserted in the innerHTML of an element.

 


Behind the scene


The function map is converting the directives to HTML attributes.
The format of these attributes is as follow:

  • pure:nodeValue=“firstName”
    To set the node value of an element to the property ‘firstName’ of the data.
  • pure:href=“http://beebole.com”
    To set the value of an attribute, here ‘href’ from the element
  • pure:repeat=“line <- lines”
    To repeat the element for each ‘lines’ in our data and call the current item ‘line’

Setting manually such “pure:” attributes will drive to the same result at the compilation
So if your HTML is like below, you’ll get exactly the same result as the example Basic – Hello Who?:

<div id="hello">
  Hello <span pure:nodeValue="firstName">World</span>

Note for Internet Explorer

IE has a very poor handling of HTML/XML namespaces.
PURE detects the browser and sets the name space to ‘pure_’ instead of the standard XML notation ‘pure:’
Nothing really interesting here, except if you have the idea to call some expandos attribute ‘pure_something’.

Last edited by pure, Mon Sep 15 05:15:12 -0700 2008
Home | Edit | New
Versions: