guigrpa / docx-templates

Template-based docx report creation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

include browser.js - SyntaxError: Private field '#comment' must be declared in an enclosing class

olivierSOW opened this issue · comments

Hi,

I would like to use your code into browser.
I include your browser.js in my webpage this way (i renamme browser.js to docx-templates.js)

<script type="module" src='../common/js/docx-templates.js'></script>
<script  type="module" src="js/export.js"></script>

in my top export.js file i add

import {createReport} from '../../common/js/docx-templates.js';

importing the js file seems to be OK, but when i enter the function which use createReport function, i get immediatly this error stack:

docx-templates.js:17  Uncaught (in promise) Error: Error executing command '#comment': SyntaxError: Private field '#comment' must be declared in an enclosing class
    at runUserJsAndGetRaw (docx-templates.js:17:7454)
    at H (docx-templates.js:17:14758)
    at U (docx-templates.js:17:13993)
    at walkTemplate (docx-templates.js:17:12985)
    at async ue (docx-templates.js:18:8491)
    at async HTMLButtonElement.OnExportClick (export.js:465:19)     /* this is my function */

Could you help me ?

I'm guessing you are using #comment as the merge tag in your template?

Because JavaScript uses # to denote private class methods, you will probably need to use a different delimiter. You may be able to use ##comment or, better still, something like {#comment#}.

Thanks @KAVA-Leigh , that sounds like a plausible reason! @olivierSOW if this does not solve your problem, please post a minimal reproducible example.

Thanx for your support, indeed, i had some code with # in the template, thanx for your quick support !