Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Brett Baggott
@BrettBaggott
I understand we shouldn't use obsolete API, this is adopted code and I want to follow the process outlined in your Upgrading to 3.5.0, but I'm being told "what we have now is good enough, we might get to that later". Problem is, this is yet to be deployed to production code. It will be replacing a website that sees about 2 million pageviews per month, and the bulk of those we be delivered via that Parse call.
So if I'm reading everything right, that particular way of calling the API will generate an assembly per request (barring any other caching mechanisms such as output cache)
Matthias Dittrich
@matthid
Yes you should at least use an overload with a name/cachename parameter to get some kind of caching...

It should actually be quite easy to see (even while debugging) if caching is in place. First its just very slow when everything is compiled, and second you can see a "csc.exe" in task manager whenever a template is compiled (which should be the one time only for every template)

Does this answer your question?

ABerg
@ABergBN
@matthid First of all great project. Thank you for that. But I have a problem, I don't know if its a bug or not. If use the deprecated TemplateService, I can Compile my templates with utf8, but if I use the suggested RazorEngineService, I get a not properly compiled template for characters like 'ä', 'ü' and so on. If you need more informations I can send you my code.
Matthias Dittrich
@matthid
@ABergBN I tried to reproduce but it seems to be working for me. A repro (for example a unit test) would be perfect. Actually the deprecated API is calling the new API internally, so it has to work somehow...
ABerg
@ABergBN
@matthid I sent you an email, with an example. It's a simple console application.
Matthias Dittrich
@matthid
@ABergBN Sorry I cannot find that mail, can you tell me to which address you sent it or try to send it again?
Matthias Dittrich
@matthid
nevermind, found it :)
I briefly looked at it: The problem is that the cshtml file is not saved with proper UTF8 encoding. So either save it via UTF8 or load it with the proper encoding.
ABerg
@ABergBN
Thanks! I loaded it with UTF8 Encoding in my ITemplateManager, but now I changed the encoding in my cshtml file and now everything works fine, thanks!
seriouz
@seriouz
Hey i want to use RazerEngine for templating hundreds of html elements like inputs, dropdowns, checkboxes etc... Is a custom implementation of the ICachingProvider the best way to go?
Matthias Dittrich
@matthid
It doesn't really depend on the size of the templates, but more on your (performance, memory) requirements and the number of your templates...
seriouz
@seriouz
there will be 20 template files (one foreach html-element) performance and memory is high (azure cloud hosted)
Matthias Dittrich
@matthid
I would recommend the default settings and use your own when you run into problems
seriouz
@seriouz
Easy use of:
string result = Engine.Razor.RunCompile(template, "input", typeof(Input), inputEl);
string result = Engine.Razor.RunCompile(template, "input", typeof(Input), inputEl2);
string result = Engine.Razor.RunCompile(template, "select", typeof(Select), selectEl);
Is the Engine.Razor. threadsafe? In my enviroment it is possible, that *Engine.Razor.RunCompile(template, "input", typeof(Input), inputEl) is called at the same time.
Matthias Dittrich
@matthid
Basically "yes", we always create a new template instance for every "Run"
If you run into any issue open one on github
seriouz
@seriouz
Okay :) I'll test is the next days (Mass compile ;>)
*it
Any idea if its possible to join this chat via IRC or similiar?
such wow... so style ... wow => https://irc.gitter.im/
Matthias Dittrich
@matthid
yeah gitter is nice :D I love all the integrations they provide :)
seriouz
@seriouz
hi from irc
Matthias Dittrich
@matthid
it seems to work! I gotta go now. Report back if your testing works ;)
seriouz
@seriouz
I#LL do! good night!
Vladimir Shmidt
@vladimir-shmidt
Hi all
Do anybody know how to use RazorEngineService with already compiled views?
There was TemplateService in RazorEngine 3
and i just do something like this
http://codepaste.net/wui5r7
but now TemplateService is obsolet
and produce exception on Run method
any help please...
Matthias Dittrich
@matthid

Yes that's by design: There are really two points here: First is template instance creation, we don't allow it as we might need to save some internal state and therefore don't want to provide an API for it (note you still can define your own type if you need to!)

The other thing is re-using ITemplate instances: We don't allow that anymore for multiple reasons. First its not thread safe and second re-using is really error prone.

There is in fact a bug in your code: nested templates (layouts or includes) are not cached properly but recompiled more than actually required...

Therefore I recommend to not use RazorEngine with the legacy API and instead use the new API (sometimes you need to do/think a bit more, but its for the greater good :)

Do you compile the templates and add them as resources? You can still make that work with a custom caching provider...
Vladimir Shmidt
@vladimir-shmidt
yep with new api i found that paradigm is changed
so i have to implement custom CachingProvider and TemplateManager
also ITemplateKey ITemplateSource and ICompiledTemplate
that is so huge overenginiring for reuse ready templates
Matthias Dittrich
@matthid
Yeah that should work
On the other hand nothing changes on the usage side...
Vladimir Shmidt
@vladimir-shmidt
"Do you compile the templates and add them as resources?" exctly
*exactly :)
Matthias Dittrich
@matthid
Sounds really interesting, is that part of your build?
Vladimir Shmidt
@vladimir-shmidt
probably part of application
we generate source via razor temapltes
sorry for misspell
that razor templates already complied with RazorGenerator tool
Matthias Dittrich
@matthid
well yes it looks over engineered, but on the other hand you could provide your implementations and other people can use it without changing their usage code (only the setup/config), which is a good thing considering the complexity here.
Vladimir Shmidt
@vladimir-shmidt
good point
thanks