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

Adding Guards 👮 #33

Merged
merged 2 commits into from
Oct 24, 2015
Merged

Adding Guards 👮 #33

merged 2 commits into from
Oct 24, 2015

Conversation

AliSoftware
Copy link
Collaborator

This PR goes on top of #32 and convert the code to modern Swift by using guard to make it waaayy more readable 😉

I kept #32 separated from this PR as they are not directly related and you might want to review them separately, but this PR still requires #32 to be merged first — as the added guard statements also apply to changes made by #32

var format:Variable?

let components = token.components()
guard components.count <= 2 else {
throw TemplateSyntaxError("'now' tags should can only have one argument: the format string `\(token.contents)`.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please switch can to may (RFC 2119)

@kylef
Copy link
Collaborator

kylef commented Oct 18, 2015

This PR still includes the changes for #32, can you remove these from this PR please.

}

public init(variable:String, loopVariable:String, nodes:[NodeType], emptyNodes:[NodeType]) {
self.variable = Variable(variable)
self.loopVariable = loopVariable
self.nodes = nodes
// TODO: Handle emptyNodes
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good spot

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wonder why the compiler didn't warn about unused variable/parameter btw, I'd expect it to suggest you a Fix-It to replace emptyNodes with _ in such cases.

@AliSoftware
Copy link
Collaborator Author

This PR still includes the changes for #32, can you remove these from this PR please.

Not really actually, as they would conflict if separated: there are guard statements added there that are on the same code regions that the ones where I added parser.eatNextCRLF() calls. Splitting those PRs would make the merge conflict much harder ^^

@AliSoftware
Copy link
Collaborator Author

You can isolate the diff between #32 and this PR here if you want to review it more easily

@AliSoftware
Copy link
Collaborator Author

Ok, this is now entirely rebased without the commits from #32 and ready to merge!

kylef added a commit that referenced this pull request Oct 24, 2015
@kylef kylef merged commit d189103 into stencilproject:master Oct 24, 2015
@kylef
Copy link
Collaborator

kylef commented Oct 24, 2015

Thanks for the pull request!

@AliSoftware AliSoftware deleted the guards branch October 24, 2015 20:30
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.

2 participants