Can we support parse v-pre to props in @vue/compiler-sfc?
What problem does this feature solve?
When I use @vue/compiler-sfc
to parse a component's ast, I found it can't parse v-pre
to props. Any other directives can be found in the AST parsing results of the corresponding attributes. So it's on purpose or it's a bug?
What does the proposed API look like?
support parse v-pre
in ast
When I use
@vue/compiler-sfc
to parse a component's ast, I found it can't parsev-pre
to props. Any other directives can be found in the AST parsing results of the corresponding attributes. So it's on purpose or it's a bug?
It is indeed on purpose.
it's not contained in the final props because it's explicitly filtered out of the props during parsing in line 558 in the code snippet above.
So it's on purpose or it's a bug? Now I have to use regexp to match v-pre
attribute between tags😥
What's the purpose of getting the v-pre
tag?
Note that v-pre
is a special directive that affects AST shape in that inside an element with v-pre
:
- Mustaches are ignored and treated as plain text
- Directives inside
v-pre
are parsed as plain attributes
This is similar to how you won't find v-if
or v-for
in node props because they are directives that directly affect the resulting AST.
What's the purpose of getting the
v-pre
tag?Note that
v-pre
is a special directive that affects AST shape in that inside an element withv-pre
:
- Mustaches are ignored and treated as plain text
- Directives inside
v-pre
are parsed as plain attributesThis is similar to how you won't find
v-if
orv-for
in node props because they are directives that directly affect the resulting AST.
Sorry for that I didn't explain my purpose clearly. My project is to find and convert Chinese characters to function CallExpresssion
in the code by parsing AST, so we can manage international copywriting automatically. In the process of parsing the AST, if meet v-pre
, I will skip this element and its child element.
I think you should maybe use some other attributes for this purpose since v-pre
has its own special meaning in templates.
emmm..., any chinese characters in an element with v-pre
, I don't need to get and convert them. But the AST node's props
is Empty so I can't judge this element with v-pre
whether or not.😂That's the code link, If you have free time, you can see it.