src/vuegister.js
function transpile(lang, text, options) {
  let plugin = `vuegister-plugin-${lang}`;

  let langs = {
    js() {
      let map = (options.maps && options.offset > 0) ?
                generateMap(text, options.file, options.offset) : null;

      return {data: text, map};
    },

    html() {
      return {data: text, map: null};
    },

    error(err) {
      let error = `Plugin ${plugin} not found.` + os.EOL + err.message;

      throw new Error(error);
    },
  };

  // allows to override default html and js methods by plugins
  try {
    return require(plugin)(text, options);
  } catch (err) {
    return (langs[lang] || langs['error'](err))();
  }
}
function transpile(lang, text, options) {
  let plugin = `vuegister-plugin-${lang}`;

  let langs = {
    js() {
      let map = (options.maps && options.offset > 0) ?
                generateMap(text, options.file, options.offset) : null;

      return {data: text, map};
    },

    html() {
      return {data: text, map: null};
    },

    error(err) {
      let error = `Plugin ${plugin} not found.` + os.EOL + err.message;

      throw new Error(error);
    },
  };

  // allows to override default html and js methods by plugins
  try {
    return require(plugin)(text, options);
  } catch (err) {
    return (langs[lang] || langs['error'](err))();
  }
}
function transpile ( lang , text , options ) { let plugin = ` ${ lang } ` ; let langs = { js ( ) { let map = ( options . maps && options . offset > 0 ) ? generateMap ( text , options . file , options . offset ) : null ; return { data : text , map } ; } , html ( ) { return { data : text , map : null } ; } , error ( err ) { let error = ` ${ plugin } ` + os . EOL + err . message ; throw new Error ( error ) ; } , } ; // allows to override default html and js methods by plugins try { return require ( plugin ) ( text , options ) ; } catch ( err ) { return ( langs [ lang ] || langs [ 'error' ] ( err ) ) ( ) ; } }
Passes given code to the external plugin.

@param {string} lang - Lang attribute from the tag.
@param {string} text - Code for the transpiler.
@param {object} options - Options, an object of the following format:
```js
{
file: string,      // 'unknown', file name
maps: boolean,     // false, provide source map
mapOffset: number, // 0, map offset
extra: object,     // {}, plugin options from the user
}
```
@return {object} Returns the following object:
```js
{
text: string, // transpiled text from plugin
map: object,  // generated source map
}
```
Passes given code to the external plugin .