Skip to content

Conversation

@sowelipililimute
Copy link
Contributor

@sowelipililimute sowelipililimute commented Aug 13, 2022

Adds a new #with() tag to make it easier to work with extend and embed tags:

#with(parent):
  #(child)
#endwith

This is similar to Go `text/template`'s `{{ with }}` statement, in that it
allows overriding the context for the contained block.
This allows passing a context parameter to #extend, which will cause it
to desugar into a #with around the extended content, instead of just
the extended content itself.
Copy link
Member

@0xTim 0xTim left a comment

Choose a reason for hiding this comment

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

Looks good on a first pass, will do a proper review when I'm at my desk

@0xTim
Copy link
Member

0xTim commented Aug 15, 2022

@pontaoski is this ready for review? You mentioned on Discord you were doing more work

@sowelipililimute
Copy link
Contributor Author

@pontaoski is this ready for review? You mentioned on Discord you were doing more work

Yea, this is ready for review. What I mentioned on Discord is basically me ADHDbraining and refactoring/rewriting most of Leaf's lexer and parser.

Copy link
Member

@0xTim 0xTim left a comment

Choose a reason for hiding this comment

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

Thanks!

@0xTim 0xTim added the semver-minor Contains new APIs label Aug 16, 2022
@0xTim 0xTim changed the title feat: add #with tag, add #with sugar for #extend Adds a new #with() tag to make it easier to embed and extend tags Aug 16, 2022
@0xTim
Copy link
Member

0xTim commented Aug 16, 2022

Original comment:

Commit One: add #with tag

This is similar to Go text/template's {{ with }} statement, in that it
allows overriding the context for the contained block.

Commit Two: add #with sugar for extend

This allows passing a context parameter to #extend, which will cause it
to desugar into a #with around the extended content, instead of just
the extended content itself.

@0xTim 0xTim merged commit 08fb9b2 into vapor:main Aug 16, 2022
@VaporBot
Copy link

These changes are now available in 1.7.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver-minor Contains new APIs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants