Crates.io | tree-sitter-vue |
lib.rs | tree-sitter-vue |
version | 0.0.3 |
source | src |
created_at | 2022-09-23 07:10:41.39765 |
updated_at | 2022-09-24 03:49:32.160363 |
description | vue grammar for the tree-sitter parsing library |
homepage | |
repository | https://github.com/xiaoxin-sky/tree-sitter-vue |
max_upload_size | |
id | 672218 |
size | 271,388 |
Vue (Vue v2.6.0 Template Syntax) grammar for tree-sitter
Note: This grammar is not responsible for parsing embedded languages, see Multi-language Documents for more info.
npm install tree-sitter-vue tree-sitter
const Parser = require("tree-sitter");
const Vue = require("tree-sitter-vue");
const parser = new Parser();
parser.setLanguage(Vue);
const sourceCode = `
<template>
Hello, <a :[key]="url">{{ name }}</a>!
</template>
`;
const tree = parser.parse(sourceCode);
console.log(tree.rootNode.toString());
// (component
// (template_element
// (start_tag
// (tag_name))
// (text)
// (element
// (start_tag
// (tag_name)
// (directive_attribute
// (directive_name)
// (directive_dynamic_argument
// (directive_dynamic_argument_value))
// (quoted_attribute_value
// (attribute_value))))
// (interpolation
// (raw_text))
// (end_tag
// (tag_name)))
// (text)
// (end_tag
// (tag_name))))
MIT © Ika