Loader for vue.js templates that allows to use django gettext template syntax
$ npm install --save-dev django-gettext-vue-loader
Add loader to your webpack.config.js
in pipeline for html-files
{
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
preLoaders: {
html: 'django-gettext-vue-loader'
}
}
}
]
}
}
{
module: {
rules: [
{
test: /\.html$/,
loaders: [
{ loader: 'vue-template-loader' },
{ loader: 'django-gettext-vue-loader' }
]
}
]
}
}
Add template
<p>{{ _('lorem ipsum dolor sit amet') }}</p>
Then require
html templates as usual
// my-component.es2015.js
import template from './templates/my-component.html';
export default {
template,
props: {
// whatever
}
}
// es2015 way
import loader from 'django-gettext-vue-loader';
// or
var loader = require('django-gettext-vue-loader');
loader(sourceString); // return transformed string
npm test
or
node tests.js