The results of beautification are not what I expect.
This is what the code looked like before:
<template>
<div>
<template v-for="item in items">
<p>{{item}}</p>
</template>
<p>this should be indented</p>
</div>
</template>
The beautified code should have looked like this:
<template>
<div>
<template v-for="item in items">
<p>{{item}}</p>
</template>
<p>this should be indented</p>
</div>
</template>
The beautified code actually looked like this:
<template>
<div>
<template v-for="item in items">
<p>{{item}}</p>
</template>
<p>this should be indented</p>
</div>
</template>
Atom Beautify: Beautify EditorHere is a link to the debug.md Gist: https://gist.github.com/hDeraj/b2cc699ac6a1caa4de9ff40a146ede90
I have:
debug.md Gist to this issueHi, I used vue-format and it doesn't have this problem with nested template tags. Unfortunately it doesn't have the option to beautify on save.
Is there any chance it will be added in the list of supported vue beautifiers?
This might be similar to https://github.com/Glavin001/atom-beautify/issues/1175
I have this same issue. Would love a fix.
The implementation for vue-format and Atom-Beautify's vue-beautifier are different, although they follow the same idea. See:
I would be happy to review and merge a Pull Request from someone else implementing a fix. Let me know if you have any questions!
I've switched from third-party-bug to bug because the code for vue-beautifier resides within Atom-Beautify. It will eventually be separated from the core after #1174 is complete.
12 beautify: (text, language, options) ->
13 return new @Promise((resolve, reject) ->
14 #regexp = /(<(template|script|style)[^>]*>)((\s|\S)*?)<\/\2>/gi
15 regexp = /(^<(template|script|style)[^>]*>)((\s|\S)*?)^<\/\2>/gim
<template> and </template> only at start of a line will take as vue template boundary, all nested template that have indent will treat as normal html tags.<script></script> the following code do not have nested problem
<template>
<template>
...
</template>
</template>
<script>
document.write('<script>alert()</script>');
</script>
Published to v0.29.19
Most helpful comment
<template>and</template>only at start of a line will take as vue template boundary, all nested template that have indent will treat as normal html tags.<script></script>the following code do not have nested problem