Open mavanmanen opened 7 years ago
such as being able to use C# directly in the code I thought a lot about this and there is what I think:
Yes this is possible. For example it can be C# code plus some sort of pre-rendering pug that translates C# code into some callback with id, from other side there is an a dictionary<id, Func
.a(href='/') @{ DateTime.Now }
will be
.a(href='/') #{callback('func0') }
=> passed to pugCompile
plus
CodeDictionary["func0"] = (Func
Need to investigate if it is possible using NodeServices, but I think it does.
From other side Pug is great template/rendering engine I admire how views becomes small, easy to read and elegant.
Why not to build own same way as was build Razor engine?
Well the idea I had is something which is definitely possible, as @ has no special meaning in pug, it will be rendered as entered, thus if you first put the view through the pug renderer and then through the razor renderer, the code will be executed as you would expect.
as @ has no special meaning in pug
does not make sense due we need pre-process pug/razor hybrid and pass a clear pug with callbacks into pugCompile. Only one issue: if it is possible to communicate to C# more than just one final callback. I'm investigating this now and will give an answer in hours.
the result: no, I see no way to get more than one, final callback using NodeServices(maybe it is possible with Edge.js but this does not metter).
Instead of it we can do this other way:
notes: we need cache pre-porcessing(also seems caching of pug is open issue, isn't it?)
It seems this repo is currently stale and not updated anymore. Out of personal interest I would love to help maintain and develop this repo. I think with the inclusion of features such as being able to use C# directly in the code would really make this a viable alternative to cshtml razor views, something I think is definitely doable and asp.net developers who also love pug would definitely love to use.