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

Passing data #81

Open
sulthanmamusa opened this issue Dec 17, 2020 · 5 comments
Open

Passing data #81

sulthanmamusa opened this issue Dec 17, 2020 · 5 comments

Comments

@sulthanmamusa
Copy link

how to send data from service to template engine ( pug, handlebars etc.. )

@smatioli
Copy link

Hi, after a lot of guessing, I discovered that this way is possible to send data to handlebars and pug:

 this.pdfService.toStream('template', {
      locals: {
        title: 'My title',
      },
    });

@riyasyash
Copy link

@smatioli if you could , please post a sample template as well where this variables are replaced.

@agusmathew
Copy link

agusmathew commented Mar 6, 2021

doctype html
html(lang="en")
  head
    title= title
    script(type='text/javascript').
  body
    h1 #{locals.title} - node template engine 
    #container.col
      if youAreUsingPug
        p You are amazing
      else
        p Get on it!
      p.
        Pug is a terse and simple templating language with a
        strong focus on performance and powerful features.

try these sample template to get the title passed as variable in your pdf

@telou1
Copy link

telou1 commented Jan 20, 2022

Hello, if you have to make an iteration, how do you pass the array data? thanks!

@agusmathew
Copy link

ul
  - var count = 0;
  each item in items
    if count < 3
      li= item.name
    - count++;

try this please

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

5 participants