跳到正文
原文
Simon Willison·· 3 天前AI 评分29

Lean Rada 用 document.currentScript 实现内联渲染的技巧

Inline rendering with document​.currentScript

AI 导读

Lean Rada 提出一种利用 document.currentScript 属性的内联渲染技巧:在脚本中定义 `$=(...n)=>document.currentScript.replaceWith(...n)`,就能得到一个极简模板语言,把当前 script 元素直接替换成传入的内容。Simon Willison 在 Link Blog 中分享了这个做法。

来源:Simon Willison · simonwillison.net