pietroppeter
pietroppeter

Reputation: 1473

Template engine in .NET

I am looking for a template engine to be used in .NET. Coming from python, I know jinja, but I was not able to find anything similar. My use case is to create SQL queries starting from vb.net objects containing information on which columns to take (eventual aliases), which tables to join...

Upvotes: 9

Views: 7667

Answers (2)

Optimax
Optimax

Reputation: 1584

There is a templating engine in .NET called Scriban (https://github.com/lunet-io/scriban), written in C#. While it was directly inspired by Shopify's liquid templating (originally written in Ruby) which is quite similar, at least in spirit, to Jinja, the author of Scriban actually admits to have been strongly influenced by Jinja.

I have subsequently extended Scriban to include things like layouts (which are called template inheritance in Jinja) and sections (called blocks in Jinja). My extension is called Scriptic and lives here on GitHub. This is the closest thing to Jinja (the Pythonic templating engine) I know on .NET.

Upvotes: 12

Kit
Kit

Reputation: 21709

You could try using T4, which is specifically meant to generate code given some text inputs. It is supported in Visual Studio.

Here are some links to get started

Upvotes: 3

Related Questions