Thanks for getting back so quick, these answers have been very good to understand what's the potential ways of achieving what i was looking for
Posts made by underfisk
-
RE: Components use third-party/assets
-
RE: Components use third-party/assets
What i meant is that loading in
beforeRender
, we are appending the head asset content before the actual template content, right? If we have nested components,beforeRender
will not only be invoked on the parent template but also on the children. What I'm trying to see is a way to avoid some templates of ours that render hundreds of templates and avoid that each one of them includes the head or any sharable asset. Does this make sense what I'm describing? -
RE: Components use third-party/assets
If we have nested components, is this going to repeat the import? I'm just worried on having multiple times, probably with the solution that you've provided to simply avoid multiple imports, it should do the trick if we use the same approach here, right? (something that checks whether the head has been added and if so just skip since the head will be available for the whole report?)
-
RE: Components use third-party/assets
I haven't tried it yet but the need for this request was based on having a "head" asset globally available and not having to load on each template, we do have standalone components/templates, and when developing we often end up importing them and it's just an extra boilerplate that I'm trying to avoid.
The idea would be to have abeforeRender
invoking the custom load asset that you've provided but even so, is there any impact on performance usingbeforeRender
to import assets? -
Avoid multiple imports of assets in components
Is there a way to make sure an asset is only loaded once? Currently, if i import a CSS asset in multiple components, once they are building I noticed they are inserted in the DOM multiple times and it would be great avoiding repeated imports (of any kind of asset)
-
Components use third-party/assets
Currently, I'm migrating "components" that are essentially sections in the old v2 format but some require tailwind or some assets. Is there any way that at least we can ensure tailwind is present in the components? I'm not sure if using
beforeRender
in a global script would eventually make it available -
RE: Internal section/components caching
That makes sense, thanks for the quick answers
I'll definitely trybeforeRender
and possibly post something here to help the others that are probably facing the same questions of mine -
RE: Internal section/components caching
Thanks for getting back to me so fast.
You mentioned that chrome HTML to pdf is not exactly "fast", what are the recommendations to speed it up when we have multiple components per sections and those components are kinda complex?Another question of mine is basically what's actually faster, external resources vs local resources (CSS, js scripts, images)
I was curious about how the images are loaded when its a local file:- If I request the same file twice, is it cached already, or will it always read directly from the disk?
- If we have multiple images, is the loading parallelized?
The questions regarding resources is that within a section that i have, we can generate hundredths of components and often they repeat the same icon multiple times, I'm trying to understand if that's something that JSReport optimizes for us
-
Internal section/components caching
I've been using JSReport for a while and something that I'm curious about (whether it is an opt-in config value or just by default) is a way to cache section/components artifacts.
A practical example would be:
Given a report that is composed of 3 sections(or components, not sure of the actual term), if only 1 section (data/dependencies) changes, I would want that the other 2 unchanged sections/component's final output/artifact is cached(or memoized) and it would just hydrate the changed piece and probably speed up the time it takes to generate.Not sure if the example above describes really well what I'm trying to achieve/request here but I'm trying to figure out ways to speed up the pdf generation
-
RE: Global helper breaking changes
@jan_blaha After testing the new version it seems to be fixed, thanks
-
RE: Global helper breaking changes
No worries, i wanted to confirm first with JSReport team to be sure if there's a new way that was introduced or if this was actually a bug
Thanks for the fast reply btw :) -
RE: Global helper breaking changes
I don't want to use it on the template content, there we use handlebars syntax, and works perfectly, i want to use it on the javascript attached to that template helpers/script (not sure exactly what name i should assign it but its the generated helpers.js file)
-
RE: Global helper breaking changes
@jan_blaha So what I mean given the referenced playground is when we attempt to use a function created inside the global helper js such as
toUpperCase
in that given example it does not work as expected. The template namemain
contains some js code for its template that loadssum
function frommymodule
but if you attempt to usetoUpperCase
it will not work
If this doesn't help i can definitely build a repro -
Global helper breaking changes
After upgrading from v2 to v3 this was one of the breaking changes to our templates, I'm not exactly sure if now the global helper content is only meant for template content and a module for the template script (if we want) OR if there's another way around
I couldn't find any reference about the helpers in the v3 migration byt shared helpers are not accessible anymore on both template content and template script, we can access the new asset script on the template content but not anymore on the template script.
From what I've seen in some playground examples, we need to export the functions from and import them on the template scriptHere's the example i'm referencing (https://playground.jsreport.net/w/anon/U9aqM8YJ). If we attempt to use
toUpperCase
inside the template script, that will throw an error -
RE: Usage of Mapbox inside JSReport
On 2.10 the only one I got working correctly is with the snippet I sent you but I'm glad I've found a possible solution. I hope this can also help the others that are trying to integrate Mapbox and run into the same issue
-
RE: Usage of Mapbox inside JSReport
@bjrmatos I did copy-paste your playground example and in my version, i get the WebGL error "Page error: Error: Failed to initialize WebGL." so I assume it might also be related to my version. Did you try running your example in version 2.10 to see if it also throws the same error?
I. did changed the recipe to HTML and it renders just fine maps but the problem seems to only happen when using chrome-pdf recipeManage to get it working using the following snippet:
<head> <script src='https://api.mapbox.com/mapbox.js/v3.3.1/mapbox.js'></script> <link href='https://api.mapbox.com/mapbox.js/v3.3.1/mapbox.css' rel='stylesheet' /> <style> body { margin: 0; padding: 0; } #map { position: absolute; top: 0; bottom: 0; width: 100%; } </style> </head> <body> <div id="map" /> <script> L.mapbox.accessToken = '<YOUR_TOKEN>'; const lat = 40 const long = -74.5 const map = L.mapbox.map('map') .setView([lat, long], 9) .addLayer(L.mapbox.styleLayer('mapbox://styles/mapbox/streets-v11')); </script> </body>
-
RE: Usage of Mapbox inside JSReport
@bjrmatos If I pass "preserveDrawingBuffer" property (be it false or true) it does not throw an error with Mapbox but does at the page level "Page error: SyntaxError: Unexpected identifier".
My current JSReport version is 2.10.0, is the playground running on v3? -
RE: Ordered lists do not have prepended number
@bjrmatos It does the trick when changing to HTML, at least i get a sense of the final output, thanks once again