Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Nikola Sivkov
@aviatrix
It wasn't rude :)
Matthias Dittrich
@matthid
It might have worked in the past because we used to try to "guess" the type with a combination of generic parameter and "model.GetType()" which often worked as expected, often worked (but not as one would imagine) and sometimes failed in some corner cases.
But from your description I would say it was a bug if it ever worked (without knowing the exact template and RazorEngine call you used)
Nikola Sivkov
@aviatrix
in my case i tried to construct a dynamic object form a dictionary
var  tpl = Razor.GetTemplate(templateHtml, new {}, pageCacheKey);
var viewbag = new DynamicViewBag();              
var ctx = new ExecuteContext(viewbag);
var result = tpl.Run(ctx);
Matthias Dittrich
@matthid
Is there something blocking you from updating to the latest API (Documentation: https://antaris.github.io/RazorEngine/index.html)
Nikola Sivkov
@aviatrix
i was't using the viewbag anyway
no, i've updated fully
but found that couple of client templates broke after the update
(writing my own CMS for clients, and whatnot )
Matthias Dittrich
@matthid
a concrete sample would be nice: the template, the old RazorEngine call and the new call
Nikola Sivkov
@aviatrix
i will try to get that to you
@matthid Good night, and thanks for the help & your time !
Matthias Dittrich
@matthid
Good night, you are welcome :)
Nikola Sivkov
@aviatrix
@matthid ping
Matthias Dittrich
@matthid
pong
Nikola Sivkov
@aviatrix
how's it going :)
Matthias Dittrich
@matthid
fine and you?
Nikola Sivkov
@aviatrix
same, same
today i'm trying another approach to see how it goes, in regards to "dynamics"
Matthias Dittrich
@matthid
good luck :)
Nikola Sivkov
@aviatrix
thank you!
i'm generating a class at runtime with reflection
Matthias Dittrich
@matthid
puh, why do you even need that?
Nikola Sivkov
@aviatrix
so i got proper linq going on :D
Matthias Dittrich
@matthid
can't you modify the templates at all?
Nikola Sivkov
@aviatrix
i can, but that's not the point of it :)
Matthias Dittrich
@matthid
or just use static types
Nikola Sivkov
@aviatrix
+ i learn butload of stuff :)
Matthias Dittrich
@matthid
ah okey :)
always a good reason to start stuff :D
Nikola Sivkov
@aviatrix
tell me about it ... got like 5 project laying around half finished
Matthias Dittrich
@matthid
only 5 ;)
Nikola Sivkov
@aviatrix
so far !
those are the ones that have code written
huraken
@huraken
hey
Is it possible to use @Html or @Url with RazorEngine ?
Josh
@joshgo
@matthid Thank you for your response
mpbill
@mpbill
are there any demo applications available?
Matthias Dittrich
@matthid
@mpbill Only the example code/docs and real life open-source applications using RazorEngine, but I don't know any demo applications right now
mpbill
@mpbill
I dont understand ITemplateKeys. how can I construct a template key when each template key requires another 'context' template key?
BaseTemplateKey tk = new NameOnlyTemplateKey("page", ResolveType.Include, new NameOnlyTemplateKey(null, ResolveType.Include, new NameOnlyTemplateKey()));
etc
mpbill
@mpbill
So far the only way I can understand how to use a template is to read the *.cshtml file with a TextReader and pass that into Engine.Razor.RunCompile(). I feel there has to be a cleaner way of doing this, especially with all the classes I am seeing like TemplateManager, CachingProvider, TemplateKey etc... I just cant seem to find a good example of how to use one or all of these to automatically parse a template which i have created in my project. any help would be much appreciated!
Matthias Dittrich
@matthid
@mpbill Well you normally don't create TemplateKey instances yourself, those should be created by the TemplateManager. The manager and the IRazorEngineService provide APIs for this. More documentation can be found here: https://antaris.github.io/RazorEngine/TemplateManager.html. NOTE: context needs to be null for at least some templates. The idea is that the context gets set by RazorEngine when an inner template is resolved, but at the same time give you a possibility to pre-compile those templates.
Matthew Abbott
@Antaris
Wowzers, first time I've been here, didn't realise this was all so active! Thanks @matthid
Matthias Dittrich
@matthid
Nice to see you here @Antaris ;)
Paul Cox
@coxp
Hi guys, have we made any progress on CoreCLR support?
Matthias Dittrich
@matthid
I don't think somebody has looked into that jet. Maybe some code needs to be disabled because coreCLR doesn't support AppDomains....