carbone icon indicating copy to clipboard operation
carbone copied to clipboard

Loving Carbone so far. Is there any way to limit which substitutions take place? Aka, only replace specific {d.value} elements.

Open jason-medeiros opened this issue 6 years ago • 3 comments

I'm generating massive reports, and want to only replace certain elements at a time. I noticed that if I have {d.value} elements in a document, and don't set a value, carbone just overwrites them with empty strings.

Is there some way to turn off this functionality? I essentially want to load a set of records into memory, run the rendering routine in carbone, produce a report, and have the empty values preserved in the generated report as {d.value} strings.

That way I can just update reports with loaded data instead of storing gigs of data in memory prior to generation.

Thanks! (Carbone is awesome btw, have used it to generate 1000 page+ reports so far with zero issues)

jason-medeiros avatar Feb 22 '19 23:02 jason-medeiros

Interesting usage :thinking:, Carbone does not have this kind of feature but this could be implemented.

viincenb avatar Feb 28 '19 09:02 viincenb

Interesting usage thinking, Carbone does not have this kind of feature but this could be implemented.

If it was just a setting in the render options, I'd absolutely appreciate it. As of right now, I'm working around it by having replacements replace themselves with the same value (aka {d.value} gets replaced with {d.value}), but it doesn't work with values that utilize a formatter routine, so it limits me greatly.

Another request would be async formatters. That way when a formatter is called, I could "await" on remote values pulled from a database/network endpoint and dynamically fill in data. Right now, the formatters are normal functions only which means waiting for async data is a no-go.

jason-medeiros avatar Mar 01 '19 23:03 jason-medeiros

Hi @jason-medeiros,

First thank for your feedback ! Your main request can be an interesting feature. We are thinking about 2 possible implementations:

  • The way you have described: enable an options to leave missing substitutions markers into the template when the value doesn't exist.
  • Print on the console warning messages when it missing markers values. We will investigate soon and come back to you.

About an async formatter, can you open a new issue "feature request" to separate requests ?

Reach me if you need help about carbone.

steevepay avatar Oct 15 '19 12:10 steevepay