Comments (17)
老规矩,发文章送1024邀请码,一切随缘~
2bd7d4ca56f52c31 | 2018-03-05 00:24:05 | 未使用 | 邀请
689e1bf281ae43ae | 2018-03-05 00:24:05 | 未使用 | 邀请
已注册,请勿再试~ 大晚上不睡觉,抢码真够迅速
2bd7d4ca56f52c31 | 2018-03-05 00:24:05 | cowboys | 2018-03-05 00:30:01 | 已邀请 |
689e1bf281ae43ae | 2018-03-05 00:24:05 | nicolaszz | 2018-03-05 00:28:25 | 已邀请
from blog.
还不如搞个一行代码获取1024邀请码😂 @Michaelooo
from blog.
大佬在1024上班?
from blog.
template-engine
regex
https://github.com/topics/template-engine
from blog.
感觉还在研究文章,码就给抢完了。
自己实现模版字符串变量实现有点意思了
from blog.
老铁 1024地址 可否私一个
from blog.
我是老实人 这个码能干吗?
from blog.
大佬开个专题:一行代码带你入门1024系列
from blog.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript">
function parseString(str, obj) { //微醺岁月的
Object.keys(obj).forEach(key => {
str = str.replace(new RegExp(`{{${key}}}`, 'g'), obj[key]);
});
return str;
}
function test(str, obj) { //我的
let _s = str.match(/\{\{([\w_$-])+\}\}/g); // let _s = str.match(/\{\{([^{}])+\}\}/g);
for(let k in _s) {
var i = _s[k].slice(2, -2);
str = str.replace(_s[k], obj[i]);
}
return str
}
const str = "{{na$me}}很厉name害{{na$me}},才{{ag-e}}岁{{cit_y}}";
const obj = {
'na$me': "jawil",
'ag-e': "15",
'cit_y': "bj"
};
console.log(parseString(str, obj));
console.log(test(str, obj));
</script>
</head>
<body>
</body>
</html>
from blog.
当数据为多层时,一行代码还是解决不了,我之前也做了一个轻量级的模板引擎,https://github.com/XinChou16/simpTpl
var data = {
name:'xxx',
hometown:{
'xxx'
}
}
from blog.
大胸弟,看你去年探讨浏览器渲染机制问题,颇感兴趣,不知道有没有输出一些博客资料呢?
from blog.
https://www.html5rocks.com/zh/tutorials/internals/howbrowserswork/
from blog.
大兄弟 你的blog不见了 改地址了么
from blog.
又出新文章了啊,路过学习了
from blog.
from blog.
function get(path, obj, fb) {
return path.split('.').reduce((res, key) => res[key] || fb, obj);
}
function parseTpl(template, map, fallback) {
return template.replace(/\${([^{]+)}/g, (match, $1) => {
const path = $1.trim();
return get(path, map, fallback || match);
});
}
export default parseTpl;
from blog.
图片有个谬误:\w 匹配字母
正解:
\w: 匹配一个单字字符(字母、数字或者下划线)。等价于 [A-Za-z0-9_]。
出处MDN
from blog.
Related Issues (20)
- test
- question
- 学习了!
- 安利一下自己为 GitHub 开发的首个 Chrome 插件—GayHub😂 HOT 51
- CSS 黑魔法小技巧,让你少写不必要的JS,代码更优雅 HOT 47
- JavaScript 优雅的实现方式包含你可能不知道的知识点 HOT 44
- blog搬家了?请放出地址呦 HOT 2
- 哥们你域名过期了 http://qdxmq.com/ HOT 1
- add方法里的数组有没有必要抽出一个config.js文件 HOT 1
- 3 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 #------------------------------------------------- # # Project created by QtCreator 2018-10-25T08:32:36 # #------------------------------------------------- QT += core gui QT += serialport greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = COMTOOLV2 TEMPLATE = app RC_FILE =main.rc # The following define makes your compiler emit warnings if you use # any feature of Qt which has been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLS HOT 2
- a == 1 && a == 2 && a == 3 输出true方法
- 前端小蜜圈链接跳转到了菠菜站了 HOT 2
- PM2部署网站的一个诡异缓存问题
- echo 127.0.0.1
- vue项目 HOT 1
- m
- 停更了?
- 三次握手与四次挥手
- 有人继续维护吗? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blog.