Mustache.jl icon indicating copy to clipboard operation
Mustache.jl copied to clipboard

Type-specific rendering

Open christopher-dG opened this issue 5 years ago • 3 comments

Is there currently a way to specify how we'd like Mustache to render a certain type? From a quick look at the code it seems like the method being called is print(io, val). Could Mustache have its own to_string(x)::String function to be overridden perhaps, then replace the existing print with print(io, to_string(val))?

christopher-dG avatar Feb 14 '20 18:02 christopher-dG

I don’t see why not. Did you want to try a PR to see if there are issues?

On Fri, Feb 14, 2020 at 1:07 PM Chris de Graaf [email protected] wrote:

Is there currently a way to specify how we'd like Mustache to render a certain type? From a quick look at the code it seems like the method being called is print(io, val). Could Mustache have its own to_string(x)::String function to be overridden perhaps, then replace the existing print with print(io, to_string(val))?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jverzani/Mustache.jl/issues/109?email_source=notifications&email_token=AADG6TGJWR4ALH2DBOZUZJ3RC3MW3A5CNFSM4KVNCZEKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4INUQMYQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADG6TBK2XJ3MG7R474KX6LRC3MW3ANCNFSM4KVNCZEA .

-- John Verzani Department of Mathematics College of Staten Island, CUNY [email protected]

jverzani avatar Feb 14 '20 18:02 jverzani

Sure thing!

On Sat, Feb 15, 2020, 1:10 AM john verzani, [email protected] wrote:

I don’t see why not. Did you want to try a PR to see if there are issues?

On Fri, Feb 14, 2020 at 1:07 PM Chris de Graaf [email protected] wrote:

Is there currently a way to specify how we'd like Mustache to render a certain type? From a quick look at the code it seems like the method being called is print(io, val). Could Mustache have its own to_string(x)::String function to be overridden perhaps, then replace the existing print with print(io, to_string(val))?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub < https://github.com/jverzani/Mustache.jl/issues/109?email_source=notifications&email_token=AADG6TGJWR4ALH2DBOZUZJ3RC3MW3A5CNFSM4KVNCZEKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4INUQMYQ , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AADG6TBK2XJ3MG7R474KX6LRC3MW3ANCNFSM4KVNCZEA

.

-- John Verzani Department of Mathematics College of Staten Island, CUNY [email protected]

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jverzani/Mustache.jl/issues/109?email_source=notifications&email_token=AEDOH6YMQX5ZOC7AJKHVODTRC3NABA5CNFSM4KVNCZEKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELZ5HWQ#issuecomment-586404826, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEDOH66X6PATXQ7GKXTZ6EDRC3NABANCNFSM4KVNCZEA .

christopher-dG avatar Feb 14 '20 18:02 christopher-dG

That's a valid point. I would use render(io, object) for the naming with Mustache.render(io, object) defaulting to print.

oliviermilla avatar Nov 07 '23 10:11 oliviermilla