Skip to content

not recognizing lang="html" (Error: unknown <template lang="html">) #46

@alxtz

Description

@alxtz

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[x] support request

Current behavior
If a vue single file template contains lang="html"
It would actually fail to run it

I've found where it went wrong, it's in index.js, the part to detect the lang type for the template.
Currently it supports pug or resultHTML, and throwing other types away.

const extractHTML = (template, templatePath) => {

  // .......

  if (!template.lang || template.lang === 'resultHTML') {
    resultHTML = template.content;
  } else if (template.lang === 'pug') {
    resultHTML = require('pug').compile(template.content)();
  } else {
    throw templatePath + ': unknown <template lang="' + template.lang + '">';
  }

  return resultHTML;
};

Expected behavior
The lang="html" should be detected and use it.

Minimal reproduction of the problem with instructions

  1. create a vue file with <template lang="html">
  2. use vue-server-renderer's renderToString util to parse it.

What is the motivation / use case for changing the behavior?

https://github.com/vuejs/vue-loader/blob/master/docs/en/options.md#loaders

Since the html-loader itself actually exists, and it's used by vue-loader default to process lang="html"

And vue-cli add the lang="html" by default, I think it would be great to add different lang in a config file.
Please tell us about your environment:

npm: 5.5.1
other dependencies: jest jest-vue-preprocessor babel-jest jsdom vue-server-renderer

  • jest-vue-preprocessor: 1.1.X
    "jest-vue-preprocessor": "^1.3.1"

  • Node version : [ OSX | Linux | Windows ]
    node: 6.9.1
    OSX: 10.13.1

  • Platform: [ OSX | Linux | Windows ]
    OSX: 10.13.1

I would love to discuss about what could be a great way to add this support for lang="html", and other langs used in vue-loader.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions