-
Notifications
You must be signed in to change notification settings - Fork 25
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
feat(parser/renderer): add user macro feature #347
Conversation
Codecov Report
@@ Coverage Diff @@
## master #347 +/- ##
==========================================
+ Coverage 86.37% 86.43% +0.06%
==========================================
Files 46 47 +1
Lines 4176 4217 +41
==========================================
+ Hits 3607 3645 +38
- Misses 425 427 +2
- Partials 144 145 +1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, @odknt 🙌
I have not seen how those macros can be registered and associated with a template when running from the CLI (using a config file for example). Is it something you plan to add in this PR? (we could also discuss about it in a subsequent PR if you prefer.
Sorry, I didn't read latest comment of the issue carefully. |
f58e764
to
96707ea
Compare
ah, I see: the name of the file is the directly associated with the macro, isn't it? In this case, could we process the filename to remove its extension, so users can name their template files to something like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requesting change with regards to how to proceed with undefined macros: do not fail, but just output the raw text as-is.
Test failed on Windows due to LF replaced with CRLF in template file. Please tell me your thoughts. |
@odknt yes, it's safe to move the content of pkg/renderer/html5/_macros/hello into a string variable at this stage. We will have to deal with files in #349 One thing though: I had a similar problem a while ago, and I was able to fix it with the following git config: |
a06be07
to
f775133
Compare
I squashed commits for cleanup. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @odknt 🙌
One last thing: could you mention this feature (along with the code example in the PR description) in the README.adoc, too? (We should probably have a separate file to list the features in the future) Then it'll be all good and I'll merge your PR.
I added a section about the feature to README.adoc, but I'm no good at English so my sentences may be terrible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for your contribution, @odknt! 🙌🎉
fixes #334
renderer.DefineMacro()
that returnsrenderer.Option
to renderer.renderer.DefineMacro()
and pass torenderer.Wrap()
.ex.