Skip to content

Render Mustache tags as typed spans#16

Draft
PiotrCzapla wants to merge 1 commit into
mainfrom
pc/mustache-placeholders
Draft

Render Mustache tags as typed spans#16
PiotrCzapla wants to merge 1 commit into
mainfrom
pc/mustache-placeholders

Conversation

@PiotrCzapla

@PiotrCzapla PiotrCzapla commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Add support for Mustache tags. This wraps placeholders, sections, comments, and partials in spans, allowing them to be styled in DOCX and SolveIt. It is enabled by default and can be turned off with mustache=False.

For styling in DOCX, we could add variable filling to the export with the proper colors, but that wouldn't always work; some Mustache markup cannot be changed this way, and we wouldn't get visual feedback in SolveIt:

Screenshot 2026-07-14 at 13 59 07

Note: This is just proposal, If accepted I'll add docs.

Comment thread src/inline.rs
attrs: Attr::with_class(class),
children: vec![Inline::Html(src[i..end].to_string())],
},
end,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We reuse existing span for simplicity instead of exposing a mustache markup in ast.

Comment thread src/inline.rs
let body = src[i + 2..end - 2].trim_start();
let class = match body.chars().next() {
Some('#' | '^' | '/') => "mustache.section",
Some('!') => "mustache.comment",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Mustache.comment is very unlikely class due to the . which minimize hitting existing styles.

Comment thread src/inline.rs
let class = match body.chars().next() {
Some('#' | '^' | '/') => "mustache.section",
Some('!') => "mustache.comment",
Some('>') => "mustache.partial",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

{{> partial}} is something we could use in fast tract to include other docx or pdf's at rendering time.

@PiotrCzapla
PiotrCzapla requested a review from jph00 July 14, 2026 12:45
@PiotrCzapla
PiotrCzapla marked this pull request as ready for review July 14, 2026 12:45
@jph00
jph00 marked this pull request as draft July 17, 2026 22:15
@jph00

jph00 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

FYI @PiotrCzapla helpful to make PRs that aren't ready as drafts. Done now.

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.

2 participants