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

Add ability to use custom delimiters #91

Merged

Conversation

annismckenzie
Copy link
Member

@annismckenzie annismckenzie commented Jul 3, 2018

This fixes #68 and introduces the ability to use custom delimiters.

Use like this:

var View = jet.NewHTMLSet("./views"))
View.Delims("[[", "]]")
<!-- file: "views/home.jet" -->
[[ extends "layouts/application.jet" ]]
[[ block body() ]]
  <main>
    This content will be yielded in the layout above.
  </main>
[[ end ]]

TODO:

  • test extensively
  • add documentation for it to the wiki

This fixes #68 and closes #98.

@annismckenzie annismckenzie requested a review from jhsx July 3, 2018 22:32
This was referenced Jul 3, 2018
@annismckenzie annismckenzie self-assigned this Jul 3, 2018
@annismckenzie annismckenzie added this to the v2.2.0 milestone Jul 3, 2018
Copy link
Member

@jhsx jhsx left a comment

Choose a reason for hiding this comment

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

we need to think a way to handle the comments also. We can bump the version for 3.0 and change the way comments work, per example an "*" after the delimiter would start a comment.

@annismckenzie
Copy link
Member Author

annismckenzie commented Jul 4, 2018

For now, I'd stay away from a) making comment delimiters dependent upon the delimiter that's used and b) from bumping to v3 unnecessarily. The use case is to use Jet templates on the server in concert with Mustache-style template languages on the client side. Vanilla Mustache uses {{! }} for the comments so I think we're fine with {* *} which personally I haven't come across anywhere.

If and when we go ahead with #93, #84 and #32 we can talk about it again because for these I really do want to bump the major.

This also adds these consts to the lexer struct when calling the
constructor.
In order to be able to set custom delimiters it's necessary to
explicitly tell it to start the lexing process. This change is
backwards compatible, albeit it's also internal because the lexer
isn't exported.
This includes unit tests – the same ones that were already there,
just with different delimiters.
This includes an integration test.
@annismckenzie
Copy link
Member Author

I think this has reasonable coverage and will not break anything. I'll rework the Wiki slightly (it only mentions the Delims via this PR) and then go ahead and merge it.

@annismckenzie
Copy link
Member Author

@annismckenzie annismckenzie merged commit 62edd43 into CloudyKit:master Aug 9, 2018
@annismckenzie annismckenzie deleted the 68-allow-custom-delimiters branch August 9, 2018 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is there currently a way to escape the default delimiters? Add custom delimiters
2 participants