-
Notifications
You must be signed in to change notification settings - Fork 58
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
Stencil 0.12 #95
Stencil 0.12 #95
Conversation
- Add `token` attribute for better errors support - Switches to resolvable where possible - Had to make the `CallableBlock` a non-`NodeType` to avoid rendering during resolvable resolution t
2bc29eb
to
a6a8966
Compare
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.
Didn't read all the tests (only seeing the diff on GitHub so not the best way to view all of them ^^), do we have enough tests especially given the changes in Macro/Call blocks, to test that they properly apply embed filters and expressions like subscripts and all?
Sources/CallMacroNodes.swift
Outdated
let parameters: [String] | ||
let nodes: [NodeType] | ||
|
||
init(parameters: [String], nodes: [NodeType], token: Token? = nil) { | ||
self.parameters = parameters | ||
self.nodes = nodes |
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.
Not sure I get the use of the token
parameter here given it's unused?
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.
It's mandatory for the new error functionality (stencilproject/Stencil#167).
Sources/MapNode.swift
Outdated
guard components.count == 4 && components[2] == "into" || | ||
components.count == 6 && components[2] == "into" && components[4] == "using" else { | ||
func hasToken(_ token: String, at index: Int) -> Bool { | ||
return components.count > (index + 1) && components[index] == token |
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.
I nitpick but I feel it's more readable to write it as index < components.count - 1
instead of the other way around
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.
Yeah I just copied this from stencil (seemed clearer instead of checking a whole bunch of indices). Will update this.
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.
Another way is to write if collection.indices ~= index
(or is it the other way around I always forget)
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.
That's the first time I see that (the match operator) used for checking bounds, interesting.
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.
Well I haven't checked if that works on indices (which is what? A collection?), I know it works on Ranges but didn't check in code that it works work with indices… so curious if that's actually possible 😉
Updated our code as needed:
token
attribute for better errors supportCallableBlock
a non-NodeType
to avoid rendering during (variable) resolvable resolution.