HTML5 Template in Action

https://developer.mozilla.org/es/docs/Web/HTML/Elemento/template

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template

https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5

https://developer.mozilla.org/en-US/docs/Web/CSS/@import

https://www.html5rocks.com/en/tutorials/webcomponents/template/

https://www.html5rocks.com/zh/tutorials/webcomponents/template/


"use strict"; /**
*
* @author xgqfrms
* @license MIT
* @copyright xgqfrms
* @description HTML5 Template
* @augments
* @example
*
*/ /* <template>
<h2>Flower</h2>
<img src="https://www.w3schools.com/tags/img_white_flower.jpg">
</template> <template>
<div class="myClass">I like: </div>
</template> */ const showContent = () => {
// let temp = document.getElementsByTagName("template")[0],
let temp = document.querySelector(`[data-tempalte="tempalte-img"]`),
clone = temp.content.cloneNode(true);
document.body.appendChild(clone);
}; const templateGenerator = (datas = [], debug = false) => {
let result = ``;
// let temp = document.getElementsByTagName("template")[1],
let temp = document.querySelector(`[data-tempalte="tempalte-links"]`),
item = temp.content.querySelector("div");
for (let i = 0; i < datas.length; i++) {
let a = document.importNode(item, true);
a.textContent += datas[i];
document.body.appendChild(a);
}
return result;
}; const arr = ["Audi", "BMW", "Ford", "Honda", "Jaguar", "Nissan"]; if (document.createElement("template").content) {
console.log("YES! The browser supports the template element");
templateGenerator(arr);
setTimeout(() => {
showContent();
}, 0);
} else {
console.error("No! The browser does not support the template element");
}

blogs

https://www.w3schools.com/html/html5_intro.asp

https://www.w3schools.com/tags/tag_template.asp

  1. The <template> tag holds its content hidden from the client.

  2. Content inside a <template> tag will not be rendered.

  3. The content can be visible and rendered later by using JavaScript.

https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_template2


<button onclick="showContent()">Show template</button> <template>
  <h2>Flower</h2>
  <img src="https://www.w3schools.com/tags/img_white_flower.jpg" width="214" height="204">
</template>

const showContent = () => {
let temp = document.getElementsByTagName("template")[0],
clone = temp.content.cloneNode(true);
document.body.appendChild(clone);
};

https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_template3


SSE: Server-Sent Event

https://www.w3schools.com/html/html5_serversentevents.asp

EventSource

Check Server-Sent Events Support

Create a new EventSource object, and specify the URL of the page sending the updates


if(typeof(EventSource) !== "undefined") {
// Yes! Server-sent events support!
var source = new EventSource("demo_sse.php");
source.onmessage = function(event) {
document.getElementById("result").innerHTML += event.data + "<br>";
};
} else {
// Sorry! No server-sent events support..
}

text/event-stream

Server-Side Code Example

For the example above to work, you need a server capable of sending data updates (like PHP or ASP).

The server-side event stream syntax is simple. Set the "Content-Type" header to "text/event-stream". Now you can start sending event streams.


<?php
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache'); $time = date('r');
echo "data: The server time is: {$time}\n\n";
flush(); ?>

https://www.w3schools.com/html/tryit.asp?filename=tryhtml5_sse



"use strict"; /**
*
* @author xgqfrms
* @license MIT
* @copyright xgqfrms
* @description HTML5 Template
* @augments
* @example
*
*/ /* <template>
<h2>Flower</h2>
<img src="https://www.w3schools.com/tags/img_white_flower.jpg">
</template> <template>
<div class="myClass">I like: </div>
</template> */ const showContent = () => {
// let temp = document.querySelector(`[data-tempalte="tempalte-img"]`);
let temp = document.getElementsByTagName("template")[0],
clone = temp.content.cloneNode(true);
document.body.appendChild(clone);
}; const templateGenerator = (datas = [], debug = false) => {
let result = ``;
// do something...
//get the template element:
let temp = document.getElementsByTagName("template")[1];
// let temp = document.querySelector(`[data-tempalte="tempalte-links"]`);
//get the DIV element from the template:
let item = temp.content.querySelector("div");
//for each item in the array:
for (let i = 0; i < datas.length; i++) {
//Create a new node, based on the template:
let a = document.importNode(item, true);
//Add data from the array:
a.textContent += datas[i];
//append the new node wherever you like:
document.body.appendChild(a);
}
return result;
}; const arr = ["Audi", "BMW", "Ford", "Honda", "Jaguar", "Nissan"]; if (document.createElement("template").content) {
console.log("YES! The browser supports the template element");
templateGenerator(arr);
setTimeout(() => {
showContent();
}, 0);
} else {
console.error("No! The browser does not support the template element");
}

responsive-html5-web-templates

https://www.mockplus.com/blog/post/free-responsive-html5-web-design-templates

https://colorlib.com/wp/free-business-website-templates/

HTML5 Template in Action的更多相关文章

  1. [MODx] 1. Add Html5 template into the MODx

    1. Connet MODx by SSH: Go to the MODx cloud; Find you current user and right click selet Edit Cloud; ...

  2. HTML5 template元素

    前言 转自http://www.zhangxinxu.com/wordpress/2014/07/hello-html5-template-tag/ 在单页面应用,我们对页面的无刷新有了更高的要求,H ...

  3. HTML5 <template>标签元素简介

    一.HTML5 template元素初面 <template>元素,基本上可以确定是2013年才出现的.干嘛用的呢,顾名思意,就是用来声明是“模板元素”. 目前,我们在HTML中嵌入模板H ...

  4. [转]HTML5 Day 4: Add Drop Down Menu to ASP.NET MVC HTML5 Template using CSS and jQuery

    本文转自:http://pietschsoft.com/post/2010/11/17/HTML5-Day-4-Add-DropDown-Menu-ASPNET-MVC-HTML5-Template- ...

  5. HTML5 Canvas in Action

    HTML5 Canvas in Action canvas 图片处理 视频编辑工具 xgqfrms 2012-2020 www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!

  6. Web Components & HTML5 & template & slot

    Web Components & HTML5 & template & slot https://developer.mozilla.org/en-US/docs/Web/HT ...

  7. HTML5 <template>

    http://www.zhangxinxu.com/wordpress/2014/07/hello-html5-template-tag/

  8. HTML语义化:HTML5新标签——template

    一.前言 当我们使用String-base的模板引擎(如Handlebars.js等)时,要么就通过外部文件存放模板文本,需要时再通过XHR或script标签加载进来:要么通过<script t ...

  9. HTML5中<template>标签的详细介绍

    HTML5中<template>标签的详细介绍(图文) 这篇文章主要介绍了HTML5中的template标签,是HTML5入门中的重要知识,需要的朋友可以参考 一.HTML5 templa ...

随机推荐

  1. 调度 GMP

    小结: 1. 当M从P的本地运行队列获取G时, 如果发现本地队列为空会尝试从其他P盗取一半的G过来,这个机制叫做Work Stealing, 2. Q M一定需要p吗? A 不一定.M正在执行原生代码 ...

  2. Zookeeper C API的学习 以及样例 很赞

    https://www.cnblogs.com/haippy/archive/2013/02/21/2920280.html

  3. loj 10127最大数

    JSOI 2008 最大数 给定一个正整数数列a1​,a2​,a3​,⋯,an​,每一个数都在0∼p–1 之间.可以对这列数进行两种操作: 添加操作:向序列后添加一个数,序列长度变成 n+1: 询问操 ...

  4. Opencart 后台getshell

    朋友实战中遇到的,帮忙看后台getshell. 修改日志文件,但是奈何找不到warning这类等级的错误,没办法控制写入的内容,通过sql报错能写入了,但是尖括号却会被实体,使用16进制一样会实体.. ...

  5. 通过Joomla的两次RCE漏洞看session反序列化

    关于Session的前置知识: session 对数据的序列化方式一共有三种: 默认是 php 处理器:session.serialize_handler = php 效果如图: 通过|分割数据,|前 ...

  6. ping、telnet

    ping用来检查网络是否通畅或者网络连接速度的命令 telnet是用来探测指定ip是否开放指定端口 Telnet 一 .关于telnet 对于Telnet的认识,不同的人持有不同的观点,可以把Teln ...

  7. HTML5.1 新增的14项特性学习

    1.防止网络钓鱼攻击 使用target=_'blank'时, 新打开的标签可以更改window.opener.location到一些钓鱼网站,它会在开放页面上代表你执行一些Javascript代码.为 ...

  8. jQuery.qrcode二维码插件生成网页二维码

    如果是一个固定的二维码,我们只需要在网上找个地方生成图片,然后放上图片就可以了.但如果是地址不固定需要根据页面来生成的话.就有两种做法,一个是后端根据页面做一个动态的二维码.一种是前端使用插件生成. ...

  9. Java——I/O,字节流与字符流,BufferedOutputStream,InputStream等(附相关练习代码)

    I/O: I/O是什么? 在程序中,所有的数据都是以流的形式进行传输或者保存. 程序需要数据的时候,就要使用输入流读取数据. 程序需要保存数据的时候,就要使用输出流来完成. 程序的输入以及输出都是以流 ...

  10. linux下安装 zookeeper-3.4.9并搭建集群环境

    本文主要记录作者在实践过程中实现在centos7环境下安装zookeeper并搭建集群的详细步骤,关于zookeeper本文将不做详细介绍,安装步骤详情如下: 前提准备:3台linux服务器(因为zo ...