<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>15454</bug_id>
          
          <creation_ts>2012-01-08 00:28:57 +0000</creation_ts>
          <short_desc>[Templates]: Consider pattern substitution</short_desc>
          <delta_ts>2015-08-04 09:27:07 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>NEEDSINFO</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          <blocked>15476</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Thaddee TYL">thaddee.tyl</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>annevk</cc>
    
    <cc>bkardell</cc>
    
    <cc>hayato</cc>
    
    <cc>mike</cc>
    
    <cc>thaddee.tyl</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>62377</commentid>
    <comment_count>0</comment_count>
    <who name="Thaddee TYL">thaddee.tyl</who>
    <bug_when>2012-01-08 00:28:57 +0000</bug_when>
    <thetext>Templates should have a substitution system, to allow flexible client-side insertion of JSON data.

Along with it, we need an IDL API to populate slots in the template.

Ideally, the template system should have the following features:

- Insert JS values, via parsers (for security: we can have a &quot;plain string&quot; parser to display strings, an &quot;html attribute&quot; parser to escape attribute-related characters such as &quot;&amp;quot;&quot;, etc.)
- Allow to iterate through iterable JS values, such as arrays and objects
- Allow conditions based on boolean values
- Have built-in parsers but allow user-defined additions
- Include templates in templates, allowing recursive templating

Open questions:

- What should the syntax look like? There was an effort for HTML templates at &lt;http://mdv.googlecode.com/svn/trunk/docs/template.html&gt; that may be of interest.
- Should insertion of values allow insertion of HTML directly? It adds power; maybe there should be a parser for that.
- I have personally designed a template system named Plate.js [1] (for server-side templating, this time) that allowed to write macros written in JS. Each macro is a way to generate formatted content, given certain data. It proved to simplify many operations.

  [1] More information, at https://raw.github.com/espadrine/ScoutCamp/master/camp/Readme.md (scroll down the page)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65871</commentid>
    <comment_count>1</comment_count>
    <who name="brian kardell">bkardell</who>
    <bug_when>2012-03-20 19:34:00 +0000</bug_when>
    <thetext>I disagree that templates should _have_ a substitution system, but I fully support the idea that they should make applying a substitution system easy.

Rather than try to force a &apos;one size fits all&apos; model, I suggest it is more worthwhile to provide a good model to define templates in the markup and a useful pattern to plug an &quot;applier&quot; in.  There are already numerous existing, well established projects that do substitution on templates as strings and if you look at how different they are in feature and philosophy - it seems infinitely better to allow individual, established (and new upstart) vendors to compete on that front.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65872</commentid>
    <comment_count>2</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2012-03-20 19:37:18 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; I disagree that templates should _have_ a substitution system, but I fully
&gt; support the idea that they should make applying a substitution system easy.
&gt; 
&gt; Rather than try to force a &apos;one size fits all&apos; model, I suggest it is more
&gt; worthwhile to provide a good model to define templates in the markup and a
&gt; useful pattern to plug an &quot;applier&quot; in.  There are already numerous existing,
&gt; well established projects that do substitution on templates as strings and if
&gt; you look at how different they are in feature and philosophy - it seems
&gt; infinitely better to allow individual, established (and new upstart) vendors to
&gt; compete on that front.

This makes sense.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65920</commentid>
    <comment_count>3</comment_count>
    <who name="Thaddee TYL">thaddee.tyl</who>
    <bug_when>2012-03-21 22:03:19 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; I disagree that templates should _have_ a substitution system, but I fully
&gt; support the idea that they should make applying a substitution system easy.

100% agreed.

&gt; Rather than try to force a &apos;one size fits all&apos; model, I suggest it is more
&gt; worthwhile to provide a good model to define templates in the markup and a
&gt; useful pattern to plug an &quot;applier&quot; in.  There are already numerous existing,
&gt; well established projects that do substitution on templates as strings and if
&gt; you look at how different they are in feature and philosophy - it seems
&gt; infinitely better to allow individual, established (and new upstart) vendors to
&gt; compete on that front.

What seems certain for me is that such a substitution system should be
hackable in JS, which means that it needs a JS api.

The way I see this mechanism is a box (the component), which is ready
to receive a certain JSON object. It applies the JSON object one item
at a time, making each of the items fit in the patterns it defines, as
if in a jigsaw puzzle.

What should the template&apos;s interface we provide look like?

Something like `render(Object model, any data)`? Should we specify the
&quot;applier&quot; in the template, not in the renderer? What do you think?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>121618</commentid>
    <comment_count>4</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2015-07-06 07:17:44 +0000</bug_when>
    <thetext>Changing the category:
  From: WebAppsWG =&gt; Components Model
  To: WHATWG =&gt; HTML</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122441</commentid>
    <comment_count>5</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2015-08-04 09:27:07 +0000</bug_when>
    <thetext>Seems this is old feedback about the original design, not against the current specification.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>