Goal: build a quick template method So we have an item template and some values to replace. Do like this way. // 1. define the parser function template(strings, …keys) { return (function(…values) { var dict = values[values.length – 1] || {}; var result = [strings[0]]; keys.forEach(function(key, i) { var value = Number.isInteger(key) ? values[key] : […]
Archive for March, 2017
25 Mar 2017
javascript easy templates
13:51 |
javascript
, tricky |
845 views
25 Mar 2017
javascript multiline strings in the code
13:40 |
javascript
, tricky |
876 views
Goal: use multiline strings in the code I have a simple string template. I want to store it in a variable but I want to forget the concatenation. We can use the following trick. var itemTemplate = `<li> <div class=”direction-r”> <div class=”flag-wrapper”> <span class =”flag”>${0}</span> <span class =”time-wrapper”>${1}</span> </div> <div class =”desc”>${2}</div> </div> </li>`; console.log(itemTemplate); […]
Goal: use multiline strings in the code I have a simple string template. I want to store it in a variable but I want to forget the concatenation. We can use the following trick. var itemTemplate = `<li> <div class=”direction-r”> <div class=”flag-wrapper”> <span class =”flag”>${0}</span> <span class =”time-wrapper”>${1}</span> </div> <div class =”desc”>${2}</div> </div> </li>`; console.log(itemTemplate); […]
13 Mar 2017
chrome t-rex fun
1:48 |
fun
|
836 views
Goal: there is no at this time 🙂 open in chrome the following chrome://network-error/-106 and press space bar or arrow up enjoy…
Goal: there is no at this time 🙂 open in chrome the following chrome://network-error/-106 and press space bar or arrow up enjoy…
8 Mar 2017
Detect AD Blocker
2:09 |
javascript
|
820 views
Goal: do we have AD blocker or not? something like this: enjoy…
Goal: do we have AD blocker or not? something like this: enjoy…