Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppressing EOL / whitespace #68

Closed
finanalyst opened this issue Jan 12, 2022 · 2 comments
Closed

Suppressing EOL / whitespace #68

finanalyst opened this issue Jan 12, 2022 · 2 comments

Comments

@finanalyst
Copy link

finanalyst commented Jan 12, 2022

Use case: I need to have one set of HMTL if data is present, another if absent.
From the documentation, the only way I can do this as follows (note the disambiguation to ensure only the Hash key is tested)

<div id="<.name>">
<?.<tail>><.tail></?>
<!.<tail>>No tail</!>
</div>

HTML is produced as expected BUT there is always an extra line added in, either one corresponding to the <!....> stanza not generating a string, or the <?.... not generating a string.

HTML renderers remove whitespace, so it does not have an impact on users, but I find it difficult when developing and debugging HTML if there is excessive whitespace.

Is there a way to suppress whitespace?

Is there a better way in Crotmp to get alternate rendering depending on a boolean test?

@jnthn
Copy link
Member

jnthn commented Jan 12, 2022

Is there a way to suppress whitespace?

Yes, any line that only contains a conditional or iteration related tag will not introduce whitespace. Thus if you instead write:

<div id="<.name>">
<?.<tail>>
<.tail>
</?>
<!.<tail>>
No tail
</!>
</div>

Then you'll not get the blank lines.

Is there a better way in Crotmp to get alternate rendering depending on a boolean test?

Not implemented yet, but the plan is that a <!>...</!> that immediately follows a positive conditional tag will do that. So it would be:

<div id="<.name>">
<?.<tail>>
<.tail>
</?>
<!>
No tail
</!>
</div>

@jnthn
Copy link
Member

jnthn commented Jan 14, 2022

Closing in favor of #69.

@jnthn jnthn closed this as completed Jan 14, 2022
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

No branches or pull requests

2 participants