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 a way to skip compilation if a certain metadata tag is set #135

Merged
merged 3 commits into from
Nov 14, 2016

Conversation

kennyjwilli
Copy link
Contributor

Right now the only way to tell Sablono to not compile the body is by type hinting it as a String or Number. Because this type hint doesn't make sense for all cases, I think it would be nice to have a short, general type hint telling Sablono to just return the form, skipping compilation. In this PR I named that type hint :! because it is short and can be thought of as "not compiled." I am totally open to other (preferably short) names though.

@r0man
Copy link
Owner

r0man commented Nov 9, 2016

Kenny, what is the use case for skipping compilation?

On 8 Nov 2016 20:53, "Kenny Williams" notifications@github.com wrote:

Right now the only way to tell Sablono to not compile the body is by type
hinting it as a String or Number. Because this type hint doesn't make sense
for all cases, I think it would be nice to have a short, general type hint
telling Sablono to just return the form, skipping compilation. In this PR I
named that type hint :! because it is short and can be thought of as "not

compiled." I am totally open to other (preferably short) names though.

You can view, comment on, or merge this pull request online at:

#135
Commit Summary

  • Add a way to skip compilation if a certain metadata tag is set
  • Add test for skipping compilation

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#135, or mute the thread
https://github.com/notifications/unsubscribe-auth/AABUPs05wRWRZuY3A45rY8fKEx6xpKbwks5q8NMhgaJpZM4Ks1pC
.

@kennyjwilli
Copy link
Contributor Author

To avoid the interpret call altogether. For example, right now this is the code Sablono would return:

(macroexpand-1 '(html
                  [:div {}
                   (function-that-returns-react-component)]))
=> (js/React.createElement "div" nil (sablono.interpreter/interpret (function-that-returns-react-component)))

With the metadata tag I added, the call to sablono.interpreter/interpret can be skipped.

(macroexpand-1 '(html
                  [:div {}
                   ^:! (function-that-returns-react-component)]))
=> (js/React.createElement "div" nil (function-that-returns-react-component))

@r0man
Copy link
Owner

r0man commented Nov 10, 2016

Ok, I would like to have more descriptive (and possibly short) name for the name of the :! type hint. Any suggestions?

@kennyjwilli
Copy link
Contributor Author

Maybe one of these: :skip, :no-c, :omit, :noop

@r0man
Copy link
Owner

r0man commented Nov 12, 2016

What about : inline ?

On 10 Nov 2016 22:24, "Kenny Williams" notifications@github.com wrote:

Maybe one of these: :skip, :no-c, :omit, :noop


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#135 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AABUPj96YMGnOMZT1atNw_WA6-rideFAks5q84uogaJpZM4Ks1pC
.

@martinklepsch
Copy link

Was concerned about the brevity of :! as well — some suggestions: :no-interpretation, :as-is, :skip-interpretation, :raw.

I also like :inline I think. It does not mention "interpretation" though which is the term used throughout the codebase, so may lead to some confusion.

The -interpretation ones could also be abbreviated like no-interpret. I guess if you use this a lot you can always make a macro to shorten it. In general I vote for the more obvious option :)

@piranha
Copy link

piranha commented Nov 12, 2016

:raw sounds nice!

@kennyjwilli
Copy link
Contributor Author

Works for me.

On Nov 12, 2016 8:35 AM, "r0man" notifications@github.com wrote:

What about : inline ?

On 10 Nov 2016 22:24, "Kenny Williams" notifications@github.com wrote:

Maybe one of these: :skip, :no-c, :omit, :noop


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#135 (comment), or
mute
the thread
<https://github.com/notifications/unsubscribe-
auth/AABUPj96YMGnOMZT1atNw_WA6-rideFAks5q84uogaJpZM4Ks1pC>
.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#135 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ACVx2P4EiX0lSwYoxhw_jNj1SsNr_Foxks5q9erRgaJpZM4Ks1pC
.

@r0man
Copy link
Owner

r0man commented Nov 13, 2016

@kennyjwilli I think I would like to go with :inline. Could you change the tag, and document this use case in the README?

@kennyjwilli
Copy link
Contributor Author

@r0man Updated metadata tag to :inline and added a section to the README.

@r0man r0man merged commit e6f5c3c into r0man:master Nov 14, 2016
@r0man
Copy link
Owner

r0man commented Nov 14, 2016

@kennyjwilli Thanks! Will cut a release soon ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants