Templating Client-Side inserting

Hello there,

I am fairly new to Frappe/ERPNext. I am trying to deliver a html template to a doctype, but I can’t find how it is done. What I have done so far:

  1. Create the html-template in the app’s public/js/templates/template_name.html

  2. Add it to the build in public/build.json as
    { “mymodule/js/mymodule.min.js” : [ “public/js/templates/template_name.html”] }

  3. Add the reference in hooks.py : app_include_js = “/assets/mymodule/js/mymodule.min.js”

  4. bench build & bench clear-cache

  5. My DocType has a html field with the name chart. I edit the my_doctype.

frappe.ui.form.on(‘DocType Name’, {
refresh(frm){
frm.set_df_property(‘chart’, ‘options’, [frappe.render_template(“template_name.html”, {jinja_var: “Hello World”})]);
frm.refresh_field(‘chart’)

It is not working though… I have searched for hours but can’t get it running.

Anybody?

Hi Canlann,

Maybe you want to lookup ‘Print format’ if I am not misunderstanding.

Bench build with hooks is for customization of public css/js.

AOL

Hey thanks for you reply,

no I am not looking for printing templates. I am looking for custom html templates

In that case, you don’t need to use bench build with hooks change.

Example in ERP:

In js file, use frappe.render_template, and create the HTML template within the doctype folder, you should be able to pass the variables as well. (for custom doctype in your own app)

But I am not sure how you can attach a custom HTML template in a customized app for an existing doctype. Maybe check other frappe API.

AOL

Thanks it is working, what is building assets for then?

would you like to please explain the correct steps now?