This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 21017 - [Templates]: handle white space inside templates in a way that allows templates to be more human readable
Summary: [Templates]: handle white space inside templates in a way that allows templat...
Status: RESOLVED WONTFIX
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: HISTORICAL - Component Model (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: Rafael Weinstein
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 15476
  Show dependency treegraph
 
Reported: 2013-02-15 19:56 UTC by Jacob Richman
Modified: 2013-02-21 22:58 UTC (History)
1 user (show)

See Also:


Attachments

Description Jacob Richman 2013-02-15 19:56:32 UTC
Most existing html template systems such as Mustache and Closure Templates strip some white space from templates.
This makes it easier for users to write templates in a way that us human readable. The issue is acute once templates support syntax for expressing conditionals. At that point, it is common for templates to have 400 characters of template code generate a single line of output.

For example, consider the following <templates> we wrote using experimental syntax to enable loops and conditionals.
https://github.com/dart-lang/dart-api-app/blob/c65256f1ac4ea680f145355c3ae204fe195b3e43/client/web/doc_link.html

These templates all need to avoid accidental white space so we end up with unreadable ~400 character lines.

-Jacob
Comment 1 Rafael Weinstein 2013-02-15 20:06:48 UTC
This is an interesting issue, but it's outside the scope of the goals for the current template element which is solely a mechanism for defining a prototype of dom fragments.

It seems to me that a scripting mechanism using the template element has sufficient semantics to implement whatever policy it chooses for dealing with whitespace.
Comment 2 John Messerly 2013-02-21 22:58:43 UTC
Hey Rafael,

We were also seeing this problem with web components:

<element name="...">
  <template>
    ... contents ...
  </template>
</element>


What's the best way to deal with it in this case?
We end up with extra whitespace text nodes.

Maybe we can deal with this when we instantiate the shadow root?