feat: ownPropertyOnly option to protect prototype, #454

This commit is contained in:
Harttle
2022-01-29 01:22:34 +08:00
committed by Harttle
parent 527858fc14
commit 7e99efc513
7 changed files with 93 additions and 9 deletions
+2
View File
@@ -128,6 +128,8 @@ it defaults to false. For example, when set to true, a blank string would evalu
**lenientIf** modifies the behavior of `strictVariables` to allow handling optional variables. If set to `true`, an undefined variable will *not* cause an exception in the following two situations: a) it is the condition to an `if`, `elsif`, or `unless` tag; b) it occurs right before a `default` filter. Irrelevant if `strictVariables` is not set. Defaults to `false`.
**ownPropertyOnly** hides scope variables from prototypes, useful when you're passing a not sanitized object into LiquidJS or need to hide prototypes from templates. Defaults to `false`.
{% note info Non-existent Tags %}
Non-existent tags always throw errors during parsing and this behavior can not be customized.
{% endnote %}
+2
View File
@@ -125,6 +125,8 @@ LiquidJS 把这个选项默认值设为 <code>true</code> 以兼容于 shopify/l
**strictVariables** 用来启用变量严格模式。如果设置为 `true` 变量不存在时渲染会抛出异常,默认为 `false` 这时不存在的变量会被渲染为空字符串。
**ownPropertyOnly** 用来隐藏原型上的变量,如果你需要把未经处理过的对象传递给模板时,可以设置 `ownPropertyOnly``true`,默认为 `false`
{% note info 不存在的标签 %}
不存在的标签总是会抛出一个解析异常,这一行为无法自定义。
{% endnote %}