Assets helper not found..?



  • Hi, sorry newbie question here :(

    I'm playing around on jsReportOnline & I can't get the asset helper to work - is there some extra config I need to do that despite searching I'm failing to see?

    This is the report file:

    <html>
    <head>
        <style>
        {{asset "./Daily Written Fee/mini.css"}}
        {{asset "./Daily Written Fee/styles.css"}}
        </style>
    </head>
    
    <h1> Daily Written Fee - Live </h1>
    
    <div>
        <span>Gross Perm Fees Written This Week: {{written_fees.perm.this_week}}</span>
    </div>
    <div>
        <span>Gross Perm Fees Written This Month: {{written_fees.perm.this_month}}</span>
    </div>
    </html>
    

    I've put the assets into the folder linked to in the asset tag, so the files do exist - but tbh, I'd expect another error if the file doesn't exist, the error to me at least, suggests it doesn't know how to handle the asset 'tag' itself.

    and this is the error I get

    Error while executing templating engine. Missing helper: "asset"
    Error: Missing helper: "asset"
        at Object.<anonymous> (/app/node_modules/handlebars/dist/cjs/handlebars/helpers/helper-missing.js:19:13)
        at Object.wrapper (/app/node_modules/handlebars/dist/cjs/handlebars/internal/wrapHelper.js:15:19)
        at Object.eval [as main] (eval at createFunctionContext (/app/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:262:23), <anonymous>:9:100)
        at main (/app/node_modules/handlebars/dist/cjs/handlebars/runtime.js:208:32)
        at ret (/app/node_modules/handlebars/dist/cjs/handlebars/runtime.js:212:12)
        at ret (/app/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:519:21)
        at /app/node_modules/jsreport-handlebars/lib/handlebarsEngine.js:33:20
        at Object.base.apply (/app/node_modules/vm2/lib/contextify.js:469:32)
        at evaluate-template-engine.js:1:64
        at Script.runInContext (vm.js:131:20)
    

    TIA.

    Steve.



  • The asset helper is part of the jsreport v3.
    Please use the syntax {#asset} mentioned in the current documentation
    https://jsreport.net/learn/assets



  • Aha! I just copied it out of some of the samples or documentation - I forget where now. I've downloaded beta 3 and am running it local now anyway - works great :)

    btw, minor bug I've found, when you copy the code from the asset page in the studio using the copy embedding code button (which by the way the tool tip has a spelling error - "coppy" not "copy") it uses the old v2 format as you mentioned above, not the v3, so if you paste it into the template you end up with an error.

    e.g.

    {#asset /test/SharedAssets/paper/custom_style.css @encoding=utf8}
    not
    {{ asset "/test/SharedAssets/paper/custom_style.css" }}


  • administrators

    hi!

    which by the way the tool tip has a spelling error - "coppy" not "copy"

    yes, thanks this is fixed now.

    it uses the old v2 format as you mentioned above, not the v3, so if you paste it into the template you end up with an error.

    yes, you are right, i see this bug in the current 3 beta, it is fixed on master, so this is going to be included in next v3 release which should happen really soon.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.