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 prefix #204

Merged
merged 4 commits into from
Jan 29, 2021
Merged

Add prefix #204

merged 4 commits into from
Jan 29, 2021

Conversation

alex2844
Copy link
Contributor

@alex2844 alex2844 commented Jan 27, 2021

fastify.register(require('../index'), {
  engine: { ejs: ejs },
  ....,
  propertyName: 'mobile'
})
fastify.register(require('../index'), {
  engine: { ejs: ejs },
  ....,
  propertyName: 'desktop'
})

reply.mobile('index-for-layout.ejs', { text })
reply.desktop('index-for-layout.ejs', { text })

Checklist

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

I would not use prefix as a name for this option as it's a common option in fastify plugins to identify a route prefix, e.g. /v1. It's best to use a different name to avoid conflicts.

Maybe propertyName, name or exposeAs.

@alex2844
Copy link
Contributor Author

I'll be back in a few hours and fix the conflict with the current version

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

could you please document this in the readme?

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Member

@zekth zekth left a comment

Choose a reason for hiding this comment

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

lgtm but what about showing the example you described in the issue?
Like having 2 different declarations with different propertynames calling different partials?

fastify.register(require('../index'), {
  engine: { ejs: ejs },
  layout: './templates/layout-mobile.hbs'
  propertyName: 'mobile'
})
fastify.register(require('../index'), {
  engine: { ejs: ejs },
  layout: './templates/layout-desktop.hbs'
  propertyName: 'desktop'
})

I think this is a revelant example to showcase this feature

README.md Outdated Show resolved Hide resolved
Co-authored-by: Vincent LE GOFF <vince.legoff@gmail.com>
@mcollina mcollina merged commit 142fb79 into fastify:master Jan 29, 2021
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.

4 participants