Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Matthias Dittrich
@matthid
or using null: Engine.Razor.RunCompile(markup, "Tatooine", TextWriter.Null, null, new Form() { Name = "droids" }); (the last two are basically the same thing)
I agree that the Intellisense is really bad for those methods but that's an IDE issue and nothing we can really do about :(
Richard Bogle
@Boggin
Sorry, I still don't get it. The first param should be a string, shouldn't it? string markup = "<my markup here/>"
It won't compile because it's not an ITemplateKey.
Matthias Dittrich
@matthid
Do my examples work when adding using RazorEngine.Templating ?
Yes, without extension methods we only have ITemplateKey overload...
Richard Bogle
@Boggin
Nope. They all have strings as the first param and the compiler is expecting ITemplateKey. It would seem that in VS 2010 & .NET 4.0 those extension methods aren't being seen. Did a previous version of RazorEngine work for the older compilers, do you think?
Matthias Dittrich
@matthid
Okey now we are on the right track.
So you can probably use the extension methods directly, like this:
RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(Engine.Razor, markup, "Tatooine", System.IO.TextWriter.Null, null, newForm() { Name = "droids" });
It's basically the same thing but resolved by hand instead of the compiler.
Richard Bogle
@Boggin
Ha! I thought we'd already tried that but yes, that's the bunny! Hurrah. Thank you so much for your time.
Matthias Dittrich
@matthid
Glad it worked! I probably add to the docs that VS 2010/Net40 needs to use the extension methods manually (even if those versions are quite ancient).
Richard Bogle
@Boggin
Heh. Yeah, they are indeed ancient but this financial institution is going to be stuck with them for a looong time! Bit sad, really.
Matthias Dittrich
@matthid
Just changed the license to Apache2!
This is now released in https://www.nuget.org/packages/RazorEngine/3.7.0-beta1. Please test and report if I broke anything.
Richard Bogle
@Boggin
@matthid I found out it wasn't the VS2010 compiler - it was me trying to pass an int to the 'name' parameter. I fixed it by putting the argument names against each parameter and also reading through the large number of overloads then calling .ToString() on the one that was incorrect. So, no need to up date your documentation.
Matthias Dittrich
@matthid
Good to know, thanks
Brett Baggott
@BrettBaggott
I posted about this on the Google Group but thought I should post it here as well. So if I understand correctly, the now obsolete Parse is, potentially, creating an assembly per request (since there is no accomodation for caching, etc.)
Matthias Dittrich
@matthid
You shouldn't use obsolete API if you don't need to. To answer your question: It depends on the overload and version you are using..
Brett Baggott
@BrettBaggott
Version 3.4.1 and called like so: var html = Razor.Parse(page.Content.Value);
where page.Content.Value is a snippet of Razor syntax pulled from data
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.
Brett Baggott
@BrettBaggott
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