Simon Willison·· 9 小时前AI 评分6
document.currentScript 实现内联渲染技巧
Inline rendering with document.currentScript
AI 导读
Lean Rada 分享利用 document.currentScript 属性进行内联渲染的技巧。通过定义 $=(...n)=>document.currentScript.replaceWith(...n) 快捷函数,开发者可构建极简模板语言。该方法允许在脚本执行时直接替换当前节点内容,简化前端动态渲染逻辑。
来源:Simon Willison · simonwillison.net