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

[Qute] Allow nested content for user defined tags #10652

Merged
merged 2 commits into from
Jul 20, 2020
Merged

[Qute] Allow nested content for user defined tags #10652

merged 2 commits into from
Jul 20, 2020

Conversation

jlannoy
Copy link
Contributor

@jlannoy jlannoy commented Jul 10, 2020

Hello.
Here is a first PR for a quick modification in Qute.

It will allow nested content in user defined tags. For a simple example, if I defined tags\my-tag.html as this :

<div class="{class}">
    {nested}
</div>

I can then call it this way :

{#my-tag class='large div'}
    <b>Hello !</b>
{\}

nested being a special key as it already is.

@jlannoy
Copy link
Contributor Author

jlannoy commented Jul 10, 2020

Can someone explain me or correct the PR to have a better (reactive) way than using a StringBuilder to manage the MultiNode results to inject into the nested var ?

gsmet
gsmet previously requested changes Jul 16, 2020
Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

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

Just a note that this will need to be squashed before merging.

@mkouba could you have a look at that one?

@mkouba
Copy link
Contributor

mkouba commented Jul 16, 2020

@jlannoy Could you pls describe your use case a little bit more? At least the expected output of your snippet would be helpful. I'm not sure I'm following...

@jlannoy
Copy link
Contributor Author

jlannoy commented Jul 16, 2020

The expected output is :

<div class="large div">
    <b>Hello !</b>
</div>

It's like the different section tags you can define in the include Qute directive. But oriented for custom tags development, so that you can have tag attributes and tag content. Like any HTML tag. It's a feature you can find in templating systems that offer kind of custom tags, like RockerBody in Rocker, <#nested /> in Freemarker... It seems a legit way to write more complex custom tags. Without this you have to write something like this, in my example :

{#my-tag class='large div' content='<b>Hello</b>' /}

Some other libraries don't allow it, like Velocity (velocimacros doesn't have this feature). I think you can achieve the same (when having a complex content) by using the set directive ; so you can decide to not support it.

@mkouba
Copy link
Contributor

mkouba commented Jul 17, 2020

Now I finally undestand! ;-) I think it's a nice feature. The only thing I'm not quite sure about is the name of the key. content, body or nested-content could be a better choice? Let me check the modifications.

@jlannoy
Copy link
Contributor Author

jlannoy commented Jul 17, 2020

For the name of the key, I used nested in reference to Freemarker. In your proposals, nested-content is the more accurate and less risky I think, to avoid collision with other user defined variables.

@mkouba mkouba added the area/qute The template engine label Jul 17, 2020
@mkouba mkouba added this to the 1.7.0 - master milestone Jul 17, 2020
@mkouba mkouba requested a review from gsmet July 17, 2020 15:04
@mkouba
Copy link
Contributor

mkouba commented Jul 17, 2020

@jlannoy I think that the current version is OK. Would you care to review my changes?

@jlannoy
Copy link
Contributor Author

jlannoy commented Jul 17, 2020

Ok for me. Thank your for your help with the CompletionStage concept :)

@mkouba mkouba requested a review from gastaldi July 20, 2020 07:59
Copy link
Contributor

@gastaldi gastaldi left a comment

Choose a reason for hiding this comment

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

That looks cool!

@mkouba mkouba dismissed gsmet’s stale review July 20, 2020 12:47

Guillaume's comments should be addressed now.

@mkouba mkouba merged commit 2ec4c58 into quarkusio:master Jul 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants