
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
babel-plugin-transform-vue-template
Advanced tools
Compile Vue template at build time via babel plugin.
yarn add babel-plugin-transform-vue-template --dev
yarn add vue-template-compiler --dev
# vue-template-compiler is required as peer dependency
With .babelrc
:
{
"plugins": ["transform-vue-template"]
}
Then every object property template
whose value is a template string literal will be compiled to render
function at build time:
export default {
template: `<div>
<button @click="whatever">Click me!</button>
</div>`,
methods: {
whatever() {
// do whatever
}
}
}
Compiled code:
export default {
render: function render() {
var _vm = this;
var _h = _vm.$createElement;
var _c = _vm._self._c || _h;
return _c('div', [_c('button', {
on: {
"click": _vm.whatever
}
}, [_vm._v("Click me!")])]);
},
staticRenderFns: [],
methods: {
whatever() {// do whatever
}
}
};
This plugin also handles tagged template expression, it simply ignores the tag:
export default {
template: html`<div>{{ message }}</div>`
}
Note that the tag name can only be html
.
Add a comment block with @transform-disable
to the previous line:
export default {
// @transform-disable
template: `<div></div>`
}
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
babel-plugin-transform-vue-template © egoist, Released under the MIT License.
Authored and maintained by egoist with help from contributors (list).
egoist.moe · GitHub @egoist · Twitter @_egoistlily
FAQs
as you can tell from the name.
The npm package babel-plugin-transform-vue-template receives a total of 325 weekly downloads. As such, babel-plugin-transform-vue-template popularity was classified as not popular.
We found that babel-plugin-transform-vue-template demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.