Skip to content

fix: preserve indentation for multiline dicts#94

Open
johnsfuller wants to merge 1 commit into
HubSpot:masterfrom
johnsfuller:codex/fix-require-js-object-indent
Open

fix: preserve indentation for multiline dicts#94
johnsfuller wants to merge 1 commit into
HubSpot:masterfrom
johnsfuller:codex/fix-require-js-object-indent

Conversation

@johnsfuller

Copy link
Copy Markdown

Fixes #93.

Summary

This updates the HubL printer so multiline dicts inherit the indentation of the HubL tag that contains them. The previous printer emitted {{ ... }} output expressions and inline {% set ... = ... %} tags without aligning nested multiline docs to the enclosing tag column, so dict entries could be printed flush with the page instead of under the expression.

Example

Input from prettier/tests/dicts.html:

{# a dict in a set tag that should line up #}
{% set test_object = {
    position: "footer",
  defer: true
}%}

{# a dict as a param #}
  {{ require_js(get_asset_url("../../scripts/super.hubl.js"), {
  position: "footer",
  defer: true
}) }}

Formatted output:

{# a dict in a set tag that should line up #}
{% set test_object = {
  position: "footer",
  defer: true
} %}

{# a dict as a param #}
{{ require_js(get_asset_url("../../scripts/super.hubl.js"), {
  position: "footer",
  defer: true
}) }}

The fixture also includes a macro call with multiple dict arguments to cover output expressions with more than one object parameter.

Validation

npm test
npx prettier prettier/tests/dicts.html --parser hubl --plugin ./prettier/dist/src/index.js

@johnsfuller

Copy link
Copy Markdown
Author

@TanyaScales not sure if this will be accepted but i did want to make sure y'all's eyes were on it!

@johnsfuller
johnsfuller marked this pull request as ready for review June 5, 2026 11:18
@johnsfuller

Copy link
Copy Markdown
Author

@joeyblake since Tanya seems busy i thought I'd tag you too... not sure if this will be accepted but i did want to make sure y'all's eyes were on it!

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.

Multiline dicts in output expressions and set tags lose indentation

1 participant