by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Paul Lee
@WalkingMist
@matthid, so there is no way to write methods to dynamically new an instance of the ViewModel from a given key or using the key to get to the template then get to the required ViewModel type?
Matthias Dittrich
@matthid
Depends on what you mean by no way. You can try to write your own caching provider with a simpler dictionary and ask it later for the type...
there is no way to know the type from a template at least. Consider for example layout templates, they can use whatever type their children is using
so I would say there is no sane way to do it. maybe some heuristic. the realquestion is what you want to achieve...
Paul Lee
@WalkingMist
@matthid, what I am trying to do is a message template engine, where I would like to have a single method to call and given the Template Key and a dictionary of parameters and be able to construct the final message. So I would like to have a method on the engine where I give it a template key and it will give me a new instance of the correct ViewModel so that I can populate it somehow
maybe it is too complex, so I have changed my mind and now the caller will construct the correct ViewModel type before passing that to the engine
Pauli Østerø
@burningice2866
Def. the way to go, no need to pass lossly typed dictionary when you can have a real class.
You can even take it a step further and decorate your ViewModel class with an attribute that holds the template key. Then the caller doesn't need to know about that, but just pass the view model and your engine can resolve the template key automatically.
Paul Lee
@WalkingMist
@burningice2866, that's a good idea!! Thank you.
Matthias Dittrich
@matthid
What Pauli says. Additionally you can already do it by creating a dynamic object from the dictionary (and use dynamic in your template)
Pauli Østerø
@burningice2866
I've created several message template engines like that mostly for emails, and that has been my approach.
Paul Lee
@WalkingMist
@burningice2866, lol, I am trying to make an email message template engine right now
@matthid I am not so sure about dynamic objects, never used it before, maybe it's time to look that up
Matthias Dittrich
@matthid
yeah use 'null' as your template type (= dynamic, see docs) and for example an expandoobject. Fill it up with your dictionary and it should work as expected...
Teck Loy Low
@Takaloy
Hi. I'm just trying out RazorEngine , going through the "getting started" guide, it doesn't seem like the documentation is up to date at all.
is there any chance to update it?
Teck Loy Low
@Takaloy
ah nevermind, figured it out. thanks!
Jelle Criel
@SnelleJelle
Hi, i'm trying out the engine and I'm having trouble using a class in my template
I can get the sample with the Anonymous Types running just fine
But I can't seem to use a List<Person> without having an exception blast in my face..
Can anyone help me out please? this is my simplified code
Teck Loy Low
@Takaloy
Hi @SnelleJelle , the example you gave doesn't seem to have a list involved
Kilian
@Schtailian
Hi, RazorEngine saves a lot of files in C:\Windows\Temp in different folders there. It deletes them when i rebuild the project but otherwise they stay there. That means we run out of memory on our production project. Shouldn't RazorEngine clean up those folders/files?
Matthias Dittrich
@matthid
Hi @Schtailian, did you take a look at http://antaris.github.io/RazorEngine/#Temporary-files and the linked issue?
Kilian
@Schtailian
Yes had a look now. We are still using Razor.Parse() so working with a template key is not an option currently. Is there a way to change the caching location? So i would move it to a location where i do not need admin rights and delete them regularly.
Brenton
@brentonlamar
Hey guys, can anyone enlighten me as to why Travis-ci is failing for pull request 400? when I run build.cmd locally, everything builds successfully.
Matthias Dittrich
@matthid
@brentonlamar No worries, it looks like a mono bug (runtime crash). As long as one of the two mono builds is green everything should be fine.
Dinesh Yelchuri
@vyelchuri
Hey guys, Can some one help me with this issue Antaris/RazorEngine#434
Dinesh Yelchuri
@vyelchuri
Hey guys, Can some one help me with this issue Antaris/RazorEngine#434
Poorya
@courosh12
Hey guys, i saw on the github page that this project is in need of new maintainers. I would like to volunteer. But i have no idea where to start, this is my first open source project. If there is anyone there who could guide me. I would appreciate that. Cheers.
Matthias Dittrich
@matthid
@courosh12 Thanks for your interest. Usually (from my experience at least) it goes like this:
  • earning some trust by fixing bugs, showing interest in the project - for example by helping users improving docs or implementing new features.
  • After a sustained amount of time people usually give you more and more rights, for example to merge and review other peoples work followed by doing releases on your own
Poorya
@courosh12
@matthid Thanx for you reply. Do you also have guidelines for the code , testing etc. Like i said i am not very experienced in this area and my qualite of code or tests may not be what is expected here.
Alok Sharma
@aloksharma1
does razor engine now supports @Url/Html or other helpers
i am also trying to get session values inside my razor code[more important then helpers]
any idea how i inject those?
Alok Sharma
@aloksharma1
@Antaris thank you for building such a beautiful tool
Keith Andrew Hill
@vic10us
I don't think so. I was hoping that c# 6.0 would be supported as well. So I could share existing MVC views with RazorEngine
Alok Sharma
@aloksharma1
well thats a disappointment , i have to write my own string parser in conjuction with razorengine in this case
i hope this wont make too much overhead
so coming to my next question
i have seen in examples how to purge all compiled dll cache
any way to remove only a single one
because only a few templates will ever change in my case
so purging all the cache will be a bit overkill
Keith Andrew Hill
@vic10us
You should implement a custom cache policy
cmellongoempyrean
@cmellongoempyrean
@vic10us if you use the Roslyn packages you can get C#6 support
Keith Andrew Hill
@vic10us
Really? I'll have to check them out.
cmellongoempyrean
@cmellongoempyrean