Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template Specification #1535

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Template Specification #1535

wants to merge 1 commit into from

Conversation

znck
Copy link
Member

@znck znck commented Apr 6, 2019

@znck znck requested review from chrisvfritz and yyx990803 and removed request for yyx990803 and chrisvfritz April 6, 2019 17:37
@octref
Copy link
Member

octref commented Apr 7, 2019

That's a good start. This would be useful for eslint-plugin-vue parser, etc, but I'm more interested in spec for the sections. For example, is <template lang="html"> allowed? How about <script lang="babel">? Should the syntax inside <style> be postcss, or <style> is reserved for CSS and people should use <style lang="postcss"> for postcss?

The current spec is pretty loose: https://vue-loader.vuejs.org/spec.html#vue-single-file-component-sfc-spec.

Copy link

@chrisvfritz chrisvfritz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good addition too. 👍 I agree with @octref that some more detail on block parsing would be great, but I think that should probably be added in a separate PR, since this one is focused on template parsing specifically.

@yyx990803
Copy link
Member

I like this! This would definitely be nice to have for tooling authors and also for ourselves (to discover and formally resolve edge cases).

One improvement we can do is to use a more formal grammar description along the lines of BNF. The ECMAScript spec uses something similar: https://www.ecma-international.org/ecma-262/9.0/index.html#sec-names-and-keywords

Screen Shot 2019-04-08 at 9 18 30 AM

There are also parser-generator tools that can take a BNF-like grammar and automatically generate parsers, e.g. antlr, jison (a JavaScript port of bison). The Antlr v4 HTML grammar files can be a good source of reference.

@yyx990803
Copy link
Member

Also, like @octref said, we also want a more well-defined version of the SFC spec. However, I think the SFC spec and the Vue template spec should be separate. The SFC spec should live inside component-compiler-utils, and the template spec should live inside Vue core repo.

@octref
Copy link
Member

octref commented Apr 8, 2019

Just today I run into an issue where spec for template would help: vuejs/vetur#1189. Would unquoted attributes be valid for Vue templates?

@yyx990803
Copy link
Member

Re unquoted attributes: should be consistent with HTML. i.e. v-if=ok is valid. It's not a recommended style but is indeed allowed.

- A JavaScript expression which must not include following characters:
- `\t` (tab)
- `\r` (carriage return)
- `\n` (new lint)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `\n` (new lint)
- `\n` (new line)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants