lukeed/tidyPublic

feat: format tempura

Tempura templates hold JavaScript in Handlebars-like tags. A port of
tempura's tag scanner turns them into the same statements that the
HTML tokenizer builds elements around: values, directives (#expect,
#var, custom blocks), and #if/#elif/#else and #each sections. JS goes
to the embed hook as __js_expression. A block in a start tag or an
attribute value is kept as written. The dialect is picked by the
syntax a file uses, or by --parser. Templates of other languages,
like robots.txt.hbs, keep their text and only re-indent block tags.

Values print as {{ value }} by default, as asked for all .hbs files;
--no-mustache-spaces gives Prettier's {{value}}.
LELuke Edwards authored
e999667Patch
Parent6665911
10 files changed+1091-34
StackedSplit
crates/tidyrs/src/handlebars/ast.rs+22 −0
crates/tidyrs/src/handlebars/error.rs+2 −0
crates/tidyrs/src/handlebars/mod.rs+104 −14
crates/tidyrs/src/handlebars/printer.rs+327 −6
crates/tidyrs/src/handlebars/tempura.rs+400 −0
crates/tidyrs/src/handlebars/text.rs+123 −0
crates/tidyrs/src/handlebars/tokenizer.rs+45 −1
crates/tidyrs/tests/handlebars.rs+39 −2
crates/tidyrs_cli/src/main.rs+24 −11
crates/tidyrs_napi/src/lib.rs+5 −0