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

Make the data-parameter of .view(page, data) for all template-engines optional. #132

Closed
florianb opened this issue Sep 17, 2019 · 1 comment

Comments

@florianb
Copy link

Before you submit an issue we recommend you drop into the Gitter community or Fastify Help and ask any questions you have or mention any problems you've had getting started with Fastify.

Please read this entire template before posting any issue. If you ignore these instructions
and post an issue here that does not follow the instructions, your issue might be closed,
locked, and assigned the missing discussion label.

🚀 Feature Proposal

Make the data-parameter of .view(page, data) for all template-engines optional.

I already created the corresponding PR #131.

This seems to catch up to the PR #52.

Motivation

I use the view-function often with implicitly provided data via the defaultContext. Currently this efforts in any case (than the pure ejs-template-handler) that an empty objeckt ({}) must be provided.

Since the pure ejs-view-function treats the data-parameter already as optional, i expected it to be optional for the other template-engines, too.

Example

Current syntax

  fastify.register(require('../index'), {
    engine: {
      'ejs-mate': require('ejs-mate')
    },
    defaultContext: { text: 'text' },
    templates: 'templates'
  })

  fastify.get('/', (req, reply) => {
    reply.view('index.ejs', {})
  })

Future syntax

  fastify.register(require('../index'), {
    engine: {
      'ejs-mate': require('ejs-mate')
    },
    defaultContext: { text: 'text' },
    templates: 'templates'
  })

  fastify.get('/', (req, reply) => {
    reply.view('index.ejs')
  })
@Eomm
Copy link
Member

Eomm commented Nov 2, 2019

#131 landed 👍

@Eomm Eomm closed this as completed Nov 2, 2019
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