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

[Question] Pass to included template current line indentation? #87

Open
soltsmank opened this issue Aug 10, 2018 · 2 comments
Open

[Question] Pass to included template current line indentation? #87

soltsmank opened this issue Aug 10, 2018 · 2 comments

Comments

@soltsmank
Copy link

soltsmank commented Aug 10, 2018

Hi,
I am working on templates for indentation sensitive format. It is critical that included multi line template and it’s children would keep parent template indentation. How is it possible to do in nice and easy way?
Is it possible to instruct parser that would automatically insert number of spaces after “\n” sign?
Thanks.

[Update] Example:

<html>
    @views.Head.template(“Home”)
</html>

Head.rocker.raw

@args (String title)

<h1>@title</h1>
<h2>Loren ipsum</h2>

Expected output to be h1 and h2 had leading 4 spaces as defined in parent template.

@jjlauer
Copy link
Member

jjlauer commented Aug 10, 2018 via email

@soltsmank
Copy link
Author

soltsmank commented Aug 10, 2018

The proposed solution defenatly would work. I did a workaround by passing variable of ident to each template and prefix each line with @indent. But this causes PLAIN_TEXT_0_1 static string const to break into a several consts.
Looks unprofessional and very dirty template.
What if to implement another method for a template class, let’s say .templateIdent(..., int additionalSpaces) which instructs the parser to store it in a variable and add it to the current variable while printing PLAIN_TEXT_0_1 with spaces after \n . So performance light loss during parsing phase only as well as clean and elegant templates.
Feasible or would break basic architecture?

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