Django gettext vue loader

Loader for vue.js templates that allows to use django gettext template syntax

Version: 0.1.4 Updated: 01/03/2019

By: PavloKovalov License: MIT

Downloads Last 30 Days: 39

django-gettext-vue-loader

Build Status Code Climate

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

License

MIT

Contributors



mr_kovalyov
commits

Dependencies


Categories: Vue js