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 leaf tag suggestion #7

Closed
wants to merge 1 commit into from

Conversation

code28
Copy link

@code28 code28 commented Oct 22, 2018

When using Lingo in a website, using Leaf as a templating engine, a tag is helpful. Because Leaf tags don't support a dictionary as parameter, I parse the body of the tag as if it would be JSON format.

To not add Leaf as a dependency, I just put the code inside the README file. Since it's not as straight forward, as one could assume, I thought it might be nice to add this suggestion into this repository.

@miroslavkovac miroslavkovac self-assigned this Oct 22, 2018
README.md Outdated
return tag.serializer.serialize(ast: body).map(to: TemplateData.self) { body in
guard let rawBodyData = String(data: body.data, encoding: .utf8),
let bodyData = "{\(rawBodyData)}".data(using: .utf8),
let interpolations = try? JSONDecoder().decode([String:String].self, from: bodyData) else {
Copy link
Contributor

Choose a reason for hiding this comment

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

The Lingo interpolations are actually [String: Any], you can pass integers as well which are then used for pluralizations.

Copy link
Author

Choose a reason for hiding this comment

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

Alright, now it supports integers as well.

@miroslavkovac
Copy link
Contributor

Addressed in #14

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

Successfully merging this pull request may close these issues.

None yet

3 participants