Skip to content

Instantly share code, notes, and snippets.

ITemplate Compile(string assemblyPath, string templateId, string input, List<string> usings)
{
var providerOptions = new Dictionary<string, string>();
providerOptions.Add("CompilerVersion", "v4.0");
ITemplate _template = null;
var usingBuilder = new StringBuilder();
foreach (var @using in _usings)
{
@vietnt
vietnt / gist:1170434
Created August 25, 2011 10:58
_new real-code
ITemplate Compile (string path, string id, string input, List<string> usings)
<- assembly.CreateInstance (typeName)
typeName = "Templates_Template_{0}_{1}".FormatWith (id, DateTime.Now.Ticks)
assembly = results.CompiledAssembly
results = provider.CompileAssemblyFromSource (options, code)
provider = new CSharpProvider
<- new Dictionary<string, string>
<- {"CompilerVersion", "v4.0"}
@vietnt
vietnt / gist:1165535
Created August 23, 2011 15:48
new language
int Sum(int[] list)
<- 0 += x in list
int Max(int[] list)
<- max = x
if x > max
x in list
max = int.MinValue
QSort(int[] list, int lo, int hi)
@vietnt
vietnt / gist:1103568
Created July 25, 2011 04:39
template_engine
// inspired by python, razor
ul
@foreach (var item in menus)
li
a [href='@item.Link']
@item.Text
p
Sum: @x + @y = @(x + y)
// inspired by stylus: http://learnboost.github.com/stylus/
// constant
transparent = 0.8
fonts = Segoe UI, Arial
// function
border-radius()
-moz-border-radius arguments
-webkit-border-radius arguments
public class Point
{
public double X;
public double Y;
public double Z;
}