-
Notifications
You must be signed in to change notification settings - Fork 90
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
Comments
I thought about your question and the only way to make it elegant would be
to modify Rocker's parser and template generator. For example, all static
text between tags/dynamic parts are grouped together and stored together.
You'd probably need to split those up by line. Then use that to count the
indent in the template generator and use that information in key parts to
add one automatically.
If you were looking for something more quick, I'd suggest you write helper
Java util's that return indented strings based on a count. Then pass the
count from template to template. For example,
```java
... in java class Util
static public String indent(int count) {
... code to create indented string
}
```
In template A
@Args(int i)
@indent(i)Your template stuff here
In template B
@import static Utils.indent
@Args(int i)
@indent(i)My template
@indent(i+1)@views.A.template(i+1)
It's not elegant per-se, but should work.
…On Fri, Aug 10, 2018 at 5:56 AM, Konstantin Soltsman < ***@***.***> wrote:
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.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#87>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAjwAglsbLXNFWz9hWC12_8ffrehbmCbks5uPVjXgaJpZM4V36r4>
.
|
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. |
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:
Head.rocker.raw
Expected output to be h1 and h2 had leading 4 spaces as defined in parent template.
The text was updated successfully, but these errors were encountered: