What is a nice templating engine to use in C#? I have XML or JSON as structured datasource. This data needs to be presented to users on the web in strict XHTML.
I've been using XSLT mostly, but maybe there are more or better options?
It needs to be used in C# or IronPython.
StringTemplate is great. I also like the Spark View Engine, which is primarily for ASP.NET MVC, but can be used on its own (the download includes a good example).
You could try Apache Velocity Engine
http://velocity.apache.org/engine/index.html
Related
What kind of framework is Razor? Is it backend or frontend?
What is the difference between the two types of frameworks?
I'm trying to learn a little bit more about backend and frontend frameworks and since I usually work with Visual Studio Asp.net MVC was wondering about it.
It is not a framework . I think you're misinterpreting certain concepts. Razor is a server side view engine, and it uses C # or VB.NET to generate dynamic content.
Razor Syntax Quick Reference
This question is a couple of years old, but I'm going to add my two cents.
People struggle to give an answer to this question because the terms 'front-end' and 'back-end' aren't formally defined anywhere. Because of that, any answer is purely subjective.
That being said, it is my opinion that the relationship between front-end/back-end and client-side/server-side isn't necessarily one-to-one
I think it helps to think of it like this: client-side and server-side are run-times, while front-end and back-end are a separation of concerns.
'Client-side' always refers to code executing on the client's machine and 'server-side' always refers to code executing on the server. A 'front-end' developer deals with displaying data to the user and getting data from the user, while a back-end developer deals with storing, manipulating, and retrieving that data.
Consider a front-end developer who is tasked with building a UI. Much of the code they write will be the typical HTML / CSS / JS. However, they will also have to deal with the data that is passed to the front-end from the backend. This is where Razor comes into play. The front-end developer will write the Razor code (which executes on the server-side) to display the data.
That is, the front-end developer will write server-side code to help generate the UI, in addition to writing the client-side code that really defines the UI.
Now, I can't imagine a scenario where a back-end developer will write client-side code.
So, to answer your question, Razor is a front-end technology that executes on the server-side runtime. It's only purpose is to generate the UI, which is the concern of the front-end.
Razor is for writing dynamic html page which is front end and c# is for writing backend logic. Although you could move all the backend logic inside razor but its highly not recommended.
Razor allows you on the back-end more easily create views (.cshtml in C#).
It is more like templating system...
http://www.asp.net/web-pages/overview/getting-started/introducing-razor-syntax-c
I have a JAVA application which using drools rules.I need create a similar application in .Net.
Can i use same drools rule file in .Net application?.
If it need to be converted ,Is there any automated way to achieve it?
A quick google search found this - http://droolsdotnet.codehaus.org/, the key bit here seems to be:
Drools.NET is a Business Rules Engine (BRE) based on Charles Forgy's Rete algorithm. Developers can now exploit a powerful Rule Engine through a completely managed .NET code base! Drools.NET is based on Jboss Rules, and comes with all the features of that Rules Engine.
So I would guess this might be what you are after from the point of view of using any existing rules and definitions - I'm assuming you'll be rewriting the code itself regardless.
Drools is a Java application, and there is no port that would enable you to re-use DRL in a .NET application.
If you want to re-use your knowledge base, then you should expose it as a web service and call that from your .NET application.
I do have some text(template), which looks like "Hello #FirstName, Welcome to #Address". The original plan was to put this text file in a view-bag and pass it through razor and it will do the job.
Now, The problem that I am facing is that my team wants this transformation to be handled by a Service, So there is no controller and there is no view here BUT there is a need to use Razor view engine's capability to replace all # with server variables.
This sounded weird to me as well but is there any way that I can extract this capability of Razor view in a way that I can use this functionality in a restful service rather than sending this data to a .cshtml file?
This is possible indeed.
Rick Strahl blogged about hosting the Razor Engine in non-web applications.
And of course, this has been asked here before.
Yes, it is possbible. The necessary steps to do that is described here: Razor View Engine without MVC at all.
I want to write a C# program which can generate a series of HTML pages based on some data grabbed from an external database. Are there any .NET based SDK which enables me to do the HTML generation? Maybe I am searching on the wrong keywords, but can't seem to find a simplistic, comprehensive answer to this. Just wondering as well, is the Google Web Toolkit an answer to my problem IF I use Java instead? Thanks for your help.
In general, I would avoid server-side HTML generation, and opt for client-side templates.
There are many options when it comes to client-side templating, but jquery-tmpl is becoming a the standard template engine for jQuery.
If you want this to tie into your data easily, consider using MVC3 with Knockout.js, as demonstrated here: http://channel9.msdn.com/Events/MIX/MIX11/FRM08
I'm new to development and want to learn JavaScript and C#, which one do you think would be best to start with. I want to mainly build web apps.
They're not mutually exclusive.
JavaScript is client-side programming (DOM manipulation, effects, AJAX).
C# is server-side programming (database communication, OO, external services, etc).
You should learn both. (and ASP.NET MVC while your at it).
That's a tough question as they are for different purposes. Do you know basic HTML and CSS already? If so, you may want to get comfortable with javascript and working with the DOM and take a look at Javascript libraries like JQuery or Prototype.
For Web development you are going to be working with either ASP.NET or ASP.NET MVC in C# and this will serve as the "behind the scenes" layer. You may want to spend some time and learn the C# language first before moving into the C# Web frameworks. Once you do that, you can work on integrating your Javascript skills.
If you have basic HTML/CSS knowledge already, than I would probably start with getting comfortable with C# and than move onto ASP(.NET or MVC). There are plenty of tutorials at asp.net. With C# and ASP there are a lot of components built in that can make building fancy ajaxy web pages easier than coding them with just javascript and html.
I would say if you want to build dynamic web applications, its more important to learn the server side first. One can do a lot of things without client side scripting, although it is important for certain types of UI.
I expect that C# will be easier, if your goal is to learn a language well, as javascript is easy to modify but to do it well requires a great deal more effort.
You can pick up on the basics of object-oriented programming easily, whereas there is a great deal of flexibility in javascript that allows you to do a great deal with little code, but with a steeper learning curve.
What is your goal? Do you want to focus on writing some innovative webpages, where you are using HTML5 features? Then javascript would be the best option, as ASP.NET MVC is not going to push the boundaries of writing games in WebGL, or using the other new features available in HTML5.
But, if you want something that will allow you more options, then C# can be used to help support web applications, as well as write desktop applications and enterprise apps, leveraging the power of .NET4.0.
But, to really use .NET4 you will either need to use mono or use some version of Visual Studio, and if you use the express version then you will have some limitations.
So, it may come down to cost, desires and goals, as to which one is better to start with, as they are very different.