Kevnz
8/4/2014 - 8:58 PM

Simple example of edge.js in mvc controller

Simple example of edge.js in mvc controller

using System.Web.Mvc;
using EdgeJs;

namespace EdgeWebApp.Controllers
{
	public class DefaultController : Controller
	{
		// GET: Default
		public ActionResult Index()
        {
			
			    dynamic data;
			    var func = Edge.Func(@"
				    return function (data, callback) {
					    var renderedTemplate = require('template-stuff')(data);//this would be whatever template functions you have
					    //be aware that modules have to be in the bin folder
					    callback(null, renderedTemplate);
					    //if there is an error you would call the callback with the error exception instead of null or some custom object
				    }
			    ");
			    ViewBag.RenderedTemplate = (string) func(data).Result;
                return View();
        }
	}
}