django-gettext-vue-loader
v0.3.0
Published
Loader for vue.js templates that allows to use django gettext template syntax
Downloads
416
Maintainers
Readme
django-gettext-vue-loader
Loader for vue.js templates that allows to use django gettext template syntax
:warning: Implementation is very raw, but usable for simple cases
Install
$ npm install --save-dev django-gettext-vue-loader
Usage (with webpack and vue-loader)
Add loader to your webpack.config.js
in pipeline for html-files
with vue-loader
{
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
preLoaders: {
html: 'django-gettext-vue-loader'
}
}
}
]
}
}
with vue-template-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
}
}
Usage (API)
// es2015 way
import loader from 'django-gettext-vue-loader';
// or
var loader = require('django-gettext-vue-loader');
loader(sourceString); // return transformed string
Run tests
npm test
or
node tests.js