Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continuation of this project #25

Open
mavanmanen opened this issue Jul 30, 2017 · 4 comments
Open

Continuation of this project #25

mavanmanen opened this issue Jul 30, 2017 · 4 comments

Comments

@mavanmanen
Copy link
Contributor

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.

@ku3mich
Copy link
Contributor

ku3mich commented Sep 14, 2017

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> in PugRendering class

.a(href='/') @{ DateTime.Now }
will be
.a(href='/') #{callback('func0') } => passed to pugCompile
plus
CodeDictionary["func0"] = (Func) () => DateTime.Now; <= invoked by NodeServices via callback

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?

@mavanmanen
Copy link
Contributor Author

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.

@ku3mich
Copy link
Contributor

ku3mich commented Sep 14, 2017

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.

@ku3mich
Copy link
Contributor

ku3mich commented Sep 15, 2017

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:

  1. Pre-process razor and extract C# code
  2. Make a dictionary [codeId, func<Model, T>]
  3. Execute all needed code from dictionary and rebuild pug with results
  4. Pass final pug into pugCompile

notes: we need cache pre-porcessing(also seems caching of pug is open issue, isn't it?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants