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

Custom HTML #11

Closed
noelmathewisaac opened this issue Jun 23, 2021 · 6 comments
Closed

Custom HTML #11

noelmathewisaac opened this issue Jun 23, 2021 · 6 comments

Comments

@noelmathewisaac
Copy link

noelmathewisaac commented Jun 23, 2021

Is it possible to pass in custom HTML as a parameter instead of pointing to a URL?
I want to generate a pdf from HTML templates (using Jinja/Nunjucks)

@lampnick
Copy link
Owner

Is it possible to pass in custom HTML as a parameter instead of pointing to a URL?
I want to generate a pdf from HTML templates (using Jinja/Nunjucks)

Do you want to use local file path?

@noelmathewisaac
Copy link
Author

Not local path. Instead of passing in URL, I wanted to pass in plain HTML directly?

@lampnick
Copy link
Owner

Not local path. Instead of passing in URL, I wanted to pass in plain HTML directly?

Could you give me an example?

@noelmathewisaac
Copy link
Author

noelmathewisaac commented Jul 1, 2021

My use case is as follows:

Let's say I have an HTML template called sample.html

<html>
   <div class="container">
      <h1 class="title">
         {{ title  }}
      </h1>
      <h2 class="subtitle">
         {{ subtitle }}
      </h2>
   </div>
</html>

I want to use a templating engine like Jinja to pass in data to the template and generate the HTML
(render_template('sample.html', title = "Foo", subtitle="bar")) to get

<html>
   <div class="container">
      <h1 class="title">
         Foo
      </h1>
      <h2 class="subtitle">
         Bar
      </h2>
   </div>
</html>

Using this generated HTML, I want to create an image or pdf.

Is there a way to do this using Docton?

@lampnick
Copy link
Owner

lampnick commented Jul 2, 2021

My use case is as follows:

Let's say I have an HTML template called sample.html

<html>
   <div class="container">
      <h1 class="title">
         {{ title  }}
      </h1>
      <h2 class="subtitle">
         {{ subtitle }}
      </h2>
   </div>
</html>

I want to use a templating engine like Jinja to pass in data to the template and generate the HTML
(render_template('sample.html', title = "Foo", subtitle="bar")) to get

<html>
   <div class="container">
      <h1 class="title">
         Foo
      </h1>
      <h2 class="subtitle">
         Bar
      </h2>
   </div>
</html>

Using this generated HTML, I want to create an image or pdf.

Is there a way to do this using Docton?

You may upload your generated html to your http server where the uri can reach by Doctron.

@noelmathewisaac
Copy link
Author

Doing this is tricky because Docton needs to fetch the HTML via a GET request. But passing in large amounts of data to an HTML template through a GET request is not easy/recommended.

It would be really useful to have an enhancement to pass in an HTML string directly. But thanks for your help!

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