Giter Site home page Giter Site logo

Comments (17)

jawil avatar jawil commented on May 21, 2024 8

老规矩,发文章送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.

jawil avatar jawil commented on May 21, 2024 3

还不如搞个一行代码获取1024邀请码😂 @Michaelooo

from blog.

deepred5 avatar deepred5 commented on May 21, 2024 1

大佬在1024上班?

from blog.

xgqfrms avatar xgqfrms commented on May 21, 2024 1

template-engine

regex

https://github.com/topics/template-engine

from blog.

ClarenceC avatar ClarenceC commented on May 21, 2024

感觉还在研究文章,码就给抢完了。
自己实现模版字符串变量实现有点意思了

from blog.

jamninetyfive avatar jamninetyfive commented on May 21, 2024

老铁 1024地址 可否私一个

from blog.

huaibaomengxiang avatar huaibaomengxiang commented on May 21, 2024

我是老实人 这个码能干吗?

from blog.

Michaelooo avatar Michaelooo commented on May 21, 2024

大佬开个专题:一行代码带你入门1024系列

from blog.

libin1991 avatar libin1991 commented on May 21, 2024
<!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>

image

from blog.

XinChou16 avatar XinChou16 commented on May 21, 2024

当数据为多层时,一行代码还是解决不了,我之前也做了一个轻量级的模板引擎,https://github.com/XinChou16/simpTpl

var data = {
   name:'xxx',
  hometown:{
       'xxx'
    }
}

from blog.

jiamianmao avatar jiamianmao commented on May 21, 2024

大胸弟,看你去年探讨浏览器渲染机制问题,颇感兴趣,不知道有没有输出一些博客资料呢?

from blog.

jawil avatar jawil commented on May 21, 2024

https://www.html5rocks.com/zh/tutorials/internals/howbrowserswork/

@jiamianmao

from blog.

huaibaomengxiang avatar huaibaomengxiang commented on May 21, 2024

大兄弟 你的blog不见了 改地址了么

from blog.

misty0304 avatar misty0304 commented on May 21, 2024

又出新文章了啊,路过学习了

from blog.

xCss avatar xCss commented on May 21, 2024

https://github.com/trix/nano

from blog.

ICELI avatar ICELI commented on May 21, 2024
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.

lq782655835 avatar lq782655835 commented on May 21, 2024

图片有个谬误:\w 匹配字母

正解:
\w: 匹配一个单字字符(字母、数字或者下划线)。等价于 [A-Za-z0-9_]。

出处MDN

from blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.