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 parse raw template in view #391

Merged
merged 3 commits into from
Sep 19, 2023

Conversation

sirenkovladd
Copy link
Contributor

@sirenkovladd sirenkovladd commented Sep 14, 2023

Fixes: #390

fastify.get('/', async (req, reply) => {
    const rawTemplate = await someRequestOrQuery(req)
    const someData = await getSomeData(req)
    reply.view({ raw: rawTemplate }, someData)
})
fastify.get('/', async (req, reply) => {
    const rawTemplate = await prepareHbsTemplate(req)
    const template = hbs.template(rawTemplate) // typeof template === 'function'
    const someData = await getSomeData(req)
    reply.view(template, someData, { layout: someLayout })
})

Checklist

@sirenkovladd
Copy link
Contributor Author

also 100% coverage

-------------------------------------|---------|----------|---------|---------|-------------------
File                                 | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
-------------------------------------|---------|----------|---------|---------|-------------------
All files                            |     100 |      100 |     100 |     100 |                   
 point-of-view                       |     100 |      100 |     100 |     100 |                   
  index.js                           |     100 |      100 |     100 |     100 |                   
 point-of-view/tap-snapshots/test    |     100 |      100 |     100 |     100 |                   
  test-ejs-with-snapshot.js.test.cjs |     100 |      100 |     100 |     100 |                   
-------------------------------------|---------|----------|---------|---------|-------------------

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.

great job!

index.js Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
Co-authored-by: Gürgün Dayıoğlu <gurgun.dayioglu@icloud.com>
Copy link
Member

@gurgunday gurgunday left a comment

Choose a reason for hiding this comment

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

Looks great!

Thanks for getting coverage up to 100%

@mcollina mcollina merged commit aaaff46 into fastify:master Sep 19, 2023
15 checks passed
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.

Support for view raw text
3 participants