Global CSS asset



  • What's the correct way to handle global CSS files.
    I've checked the "Shared helpers attached to each template" checkbox. I run the main report and get the following error

    Error while executing templating engine. Unexpected token *
    evaluate-template-engine-helpers.js:2
      * {
    

    If I wrap my style sheet in <style> tags the error becomes

    Error while executing templating engine. Unexpected token *
    evaluate-template-engine-helpers.js:2
      <
    

    Whatever the first character of the stylesheet is.

    https://playground.jsreport.net/w/carl.blanchard/RaMaFICD



  • @jan_blaha any ideas?



  • "Shared helpers attached to each template" - this is really just for javascript helpers in terms of templating engines, not for css.

    I would start with embedding every css asset explicitly to every template. Then when you find it tedious create another asset that groups styles assets into one

    <style>
      {#asset globalcss1.css}
      {#asset globalcss2.css}
      ...
    </style>
    


  • It makes NO sense, NOT having CSS files shared across all templates.
    My reports have a common theme, i.e. a single CSS file, surely loading the CSS into every template is not efficient?



  • We didn't find a good technical solution for it.
    We would need to parse the html, find the head tag using regexp and put there some artificial content.
    We didn't like such solution so we decided to keep it up to developers.

    You have plenty of options to do it on your own. Take a look for example on this demo.
    https://playground.jsreport.net/w/admin/gOs~ceO1



  • The best products out there are not always technical masterpieces.
    They are ones that just work. Now I'm no expert but most reporting systems would allow this kind of content to be shared by all reports without having to manually include everywhere.


Log in to reply
 

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