tree-sitter-htmlx 0.1.7

Tree-sitter grammar for HTMLX (expression-enhanced HTML)
Documentation

Tree-sitter grammar for HTMLX (expression-enhanced HTML)

HTMLX extends HTML with expression syntax commonly used in modern frontend frameworks like Svelte, Vue, and others.

Features

  • Expression interpolation: {expression}
  • Shorthand attributes: {name} (equivalent to name={name})
  • Spread attributes: {...props}
  • Directive attributes: bind:value, on:click, class:active, etc.

Example

use tree_sitter_htmlx::LANGUAGE;

let mut parser = tree_sitter::Parser::new();
parser.set_language(&LANGUAGE.into()).expect("Failed to load HTMLX grammar");

let source = r#"<div class="container" {hidden}>
  <p>{greeting}, {name}!</p>
  <button onclick={handleClick}>Click me</button>
</div>"#;

let tree = parser.parse(source, None).unwrap();
assert!(!tree.root_node().has_error());