Lines Matching refs:template
18 * HTML templates. The template is edited in place. I.e. in order to
19 * instantiate a template, clone it from the DOM first, and then
20 * process the cloned template. This allows for updating of templates:
34 * fragment that is used as template.
49 * template processing attribute values on a template node.
55 * Name of the property that caches the parsed template processing
56 * attribute values on a template node.
82 * HTML template processor. Data values are bound to HTML templates
84 * jsvalues. The template is modifed in place. The values of those
91 * @param {Element} template DOM node of the template. This will be
93 * template that, if processed again with the same data, will remain
97 * information while processing the template. Only takes effect
100 function jstProcess(context, template, opt_debugging) {
102 JstProcessor.prepareTemplate_(template);
105 * Caches the document of the template node, so we don't have to
109 processor.document_ = ownerDocument(template);
112 context, template));
131 * suvives cloneNode() and thus cloned template nodes can share the
163 * values. (For example when two different nodes in a template share the same
188 * Prepares the template: preprocesses all jstemplate attributes.
190 * @param {Element} template
192 JstProcessor.prepareTemplate_ = function(template) {
193 if (!template[PROP_jstcache]) {
194 domTraverseElements(template, function(node) {
220 * Prepares a single node: preprocesses all template attributes of the
417 * current template node), or directly from here if there is none.
421 * @param {Element} template
423 JstProcessor.prototype.jstProcessOuter_ = function(context, template) {
426 var jstAttributes = me.jstAttributes_(template);
432 domReplaceChild(tr, template);
437 domRemoveNode(template);
444 me.jstSelect_(context, template, select);
446 me.jstProcessInner_(context, template);
461 * @param {Element} template
463 JstProcessor.prototype.jstProcessInner_ = function(context, template) {
466 var jstAttributes = me.jstAttributes_(template);
472 var shouldDisplay = context.jsexec(display, template);
474 displayNone(template);
477 displayDefault(template);
485 me.jstVars_(context, template, values);
490 me.jstValues_(context, template, values);
504 context.jsexec(expressions[i], template);
510 var shouldSkip = context.jsexec(skip, template);
524 me.jstContent_(context, template, content);
530 for (var c = template.firstChild; c; c = c.nextSibling) {
544 * array, the current template node is multiplied once for every
547 * current template node is dropped. If the value is not an array,
552 * @param {Element} template The currently processed node of the template.
559 JstProcessor.prototype.jstSelect_ = function(context, template, select) {
562 var value = context.jsexec(select, template);
564 // Enable reprocessing: if this template is reprocessed, then only
566 // processing of a new template.
567 var instance = domGetAttribute(template, ATT_instance);
590 // For an empty array, keep the first template instance and mark
591 // it last. Remove all other template instances.
593 domSetAttribute(template, ATT_instance, STRING_asteriskzero);
594 displayNone(template);
596 domRemoveNode(template);
600 displayDefault(template);
601 // For a non empty array, create as many template instances as
602 // are needed. If the template is first processed, as many
603 // template instances are needed as there are values in the
604 // array. If the template is reprocessed, new template instances
605 // are only needed if there are more array values than template
607 // replicating the last template instance.
609 // When the template is first processed, there is no jsinstance
622 var node = domCloneNode(template);
623 domInsertBefore(node, template);
632 // Push the originally present template instance last to keep
634 // created template instances are inserted *before* the
636 jstSetInstance(template, value, i);
638 queue.push(me.jstProcessInner_, clone, template,
644 jstSetInstance(template, value, instance);
647 queue.push(me.jstProcessInner_, clone, template,
651 domRemoveNode(template);
656 displayNone(template);
658 displayDefault(template);
661 queue.push(me.jstProcessInner_, clone, template,
677 * @param {Element} template Currently processed template node.
685 JstProcessor.prototype.jstVars_ = function(context, template, values) {
688 var value = context.jsexec(values[i+1], template);
697 * starts with '$', javascript properties of the current template node
699 * template node (otherwise). Since DOM attribute values are always
705 * @param {Element} template Currently processed template node.
713 JstProcessor.prototype.jstValues_ = function(context, template, values) {
716 var value = context.jsexec(values[i+1], template);
725 // the current template node. The name may have further dot
731 var nameSpaceObject = template;
744 // template node.
749 domSetAttribute(template, label, label);
751 domRemoveAttribute(template, label);
754 domSetAttribute(template, label, STRING_empty + value);
764 * and assigns its string value to the content of the current template
769 * @param {Element} template Currently processed template node.
774 JstProcessor.prototype.jstContent_ = function(context, template, content) {
779 var value = STRING_empty + context.jsexec(content, template);
780 // Prevent flicker when refreshing a template and the value doesn't
782 if (template.innerHTML == value) {
785 while (template.firstChild) {
786 domRemoveNode(template.firstChild);
789 domAppendChild(template, t);
794 * Caches access to and parsing of template processing attributes. If
795 * domGetAttribute() is called every time a template attribute value
798 * @param {Element} template A DOM element node of the template.
800 * @return {Object} A javascript object that has all js template
803 JstProcessor.prototype.jstAttributes_ = function(template) {
804 if (template[PROP_jstcache]) {
805 return template[PROP_jstcache];
808 var jstid = domGetAttribute(template, ATT_jstcache);
810 return template[PROP_jstcache] = JstProcessor.jstcache_[jstid];
813 return JstProcessor.prepareNode_(template);
819 * call to get hold of a template from its ID.
823 * returning the template.
825 * @param {string} name The ID of the HTML element used as template.
829 * @return {Element|null} The DOM node of the template. (Only element nodes
851 * This function is the same as 'jstGetTemplate' but, if the template
854 * @param {string} name The ID of the HTML element used as template.
858 * @return {Element} The DOM node of the template. (Only element nodes
904 * @param {Document} doc The document to create the template in.
933 * @param {Element} template The template DOM node to set the instance
937 * values of which the template node will render one instance.
939 * @param {number} index The index of this template node in values.
941 function jstSetInstance(template, values, index) {
943 domSetAttribute(template, ATT_instance, CHAR_asterisk + index);
945 domSetAttribute(template, ATT_instance, STRING_empty + index);
953 * @param {Element} template The template node being processed.
954 * @param {Object} jstAttributeValues The jst attributes of the template node.
957 caller, template, jstAttributeValues) {