question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Helpers for types

See original GitHub issue
var tpl = Handlebars.Compile("{{x}}");
var o = new { x = new List<int>() {1,2,3}};
Console.WriteLine(tpl(o));

returns ToString() of my list (System.Collections.Generic.List`1[System.Int32]). How it would be possible to assign default renderer/helper for types?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:22 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
Dissimiliscommented, Nov 4, 2016

My key points are:

  • Seeing System.Collections.Generic.List1[System.Int32] gibberish in rendered template looks not right
  • Using hardcoded value.ToString() (and internal EncodedTextWriter) limits extensibility
  • Handlebarsjs renders nice [1,2,"x","y"] from collection but Handlebars.Net renders System.Collections.Generic.List1[System.Object]
  • Allowing to specify custom IEncodedTextWriter or Func<object,string> in HandlebarsConfiguration should not add any complexity or performance penalty.

IMHO library should be as extensible, as possible and I shouldn’t need to fork for such a simple thing. Forget about type helpers, but please think about interchangeable EncodedTextWriter. I will make pull request if you are willing to accept it 😃

1reaction
Dissimiliscommented, Nov 7, 2016

Hi, @JvanderStad. I know how to create helpers, that not what I need. I need to be able to override strigification, which is now hardoced in file EncodedTextWriter.cs. Reasons for this might be many, but mine is that I have no ability to change existing and future templates.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Type Helpers
A type helper is a type that can accept other types as arguments. ... We pass in the types string and string as...
Read more >
Documentation - Utility Types
Constructs a type with all properties of Type set to optional. This utility will return a type that represents all subsets of a...
Read more >
Introducing Type Helpers
Type Helpers allow us to create functions that can return other types. They are the basis for many of TypeScript's core features.
Read more >
Type Helpers for basic types
The sysutils unit contains type helpers for basic language types: boolean, ordinals (shortint, smallint, byte, word, integer, cardinal, int64, wqord, ...
Read more >
Type helpers
XState makes several type helpers available to you for composing types in TypeScript. You can use these helpers for creating custom functions or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found