Skip to content

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

Notifications You must be signed in to change notification settings

PavloKovalov/django-gettext-vue-loader

Repository files navigation

django-gettext-vue-loader

Build Status Code Climate

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

⚠️ 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

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published