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

Use template engine that supports nested objects #3

Closed
mokkabonna opened this issue Oct 9, 2017 · 7 comments
Closed

Use template engine that supports nested objects #3

mokkabonna opened this issue Oct 9, 2017 · 7 comments

Comments

@mokkabonna
Copy link

Would you be willing to change the template engine you are currently using to one that supports nested objects? Or at least property names with a dot in them?

I have created this plugin: https://github.com/mokkabonna/vue-vuelidate-jsonschema

It exposes to $params the schema that belongs to the property:

schemaPattern: {
  schema: {
    type: 'string',
    title: 'Name',
    description: 'The name of the student.',
    pattern: '^\\w+\s\\w+$',
    default: 'Jack'
  }
}

But I can't reference it in the message templates since string-template does not support nested objects. Or object names with dots in them. There is a PR open to Matt-Esch/string-template#19 fix that, but it's quite old.

One option is https://www.npmjs.com/package/es6-template-strings

@dobromir-hristov
Copy link
Owner

I used the string-template library as I wanted the templates to be the same format as the ones that vue-i18n supports - with a single curly bracket. I will search for another plugin that uses that style.
Changing to es6-template-strings would mean a breaking change as current templates wont be supported any more.

@dobromir-hristov
Copy link
Owner

https://github.com/sindresorhus/pupa
https://www.npmjs.com/package/micromustache - Not the same syntax, but supports all kinds of deep access, arrays, objects etc.

@dobromir-hristov
Copy link
Owner

@mokkabonna Tried pupa today and it has deep nesting and seems to work OK. Will do a release today with some changes to the template naming, as well as some new helper functions.

Will start adding proper tests after that.

@mokkabonna
Copy link
Author

Sounds good, thanks!

@dobromir-hristov
Copy link
Owner

@mokkabonna try it and tell me if you find issues.

@mokkabonna
Copy link
Author

mokkabonna commented Oct 11, 2017

That seems to be working just as expected, thanks! Tested with deep nesting. Closing.

I see you skipped using a templating library at all.

@dobromir-hristov
Copy link
Owner

Yep :) No need to for now. Will clean it up a bit when I get more time.

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

No branches or pull requests

2 participants