I am trying to use the new html5 template tag to make a semi-generic form that can be placed in multiple use cases without using too much javascript.
Here is a fiddle showing what I have http://jsfiddle.net/684uH/
my goal is to replace the "Name" in the placeholder text with what would would typically be found in the <content>
tag
a hypothetical example to get my point accross would be:
<div id = "hoster">
<span class = "inputPlaceholder">Special Name</span>
</div>
<template id = "im-a-template">
<input type="text" placeholder = <content select = ".inputPlaceholder"></content>>
</template>
Is there a way to do something similar or is the only way using javascript to set it manually?
Use XSLT on the client to do this:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="html5.xhtml"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml"
>
<xsl:output method="xml" encoding="utf-8" version="" indent="yes" standalone="no" media-type="text/html" omit-xml-declaration="no" doctype-system="about:legacy-compat" />
<!-- Run default templates on the xsl-stylesheet element above-->
<xsl:template match="xsl:stylesheet">
<xsl:apply-templates/>
</xsl:template>
<!-- Run this template on the root node -->
<xsl:template match="/">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>
<body>
<div id="hoster">
<span class="inputPlaceholder">Special Name</span>
</div>
<!-- Reuse the value of the node with the inputPlaceholder class -->
<template id="im-a-template">
<input type="text" placeholder="{//node()[@class='inputPlaceholder']}"/>
</template>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Use the following process:
html5.xhtml
(or change the <?xml-stylesheet href
to the name of your choice) <template>
polyfill of your choice References
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.