Add react tag helper. Clean up code and make it more consistent.

This commit is contained in:
SteveSandersonMS
2015-11-04 12:19:43 -08:00
parent e410affbd8
commit 7c3d22c7b6
14 changed files with 146 additions and 63 deletions

View File

@@ -0,0 +1,24 @@
using System.Threading.Tasks;
namespace Microsoft.AspNet.NodeServices.Angular
{
public static class AngularRenderer
{
private static StringAsTempFile nodeScript;
static AngularRenderer() {
// Consider populating this lazily
var script = EmbeddedResourceReader.Read(typeof (AngularRenderer), "/Content/Node/angular-rendering.js");
nodeScript = new StringAsTempFile(script); // Will be cleaned up on process exit
}
public static async Task<string> RenderToString(INodeServices nodeServices, string componentModuleName, string componentExportName, string componentTagName, string requestUrl) {
return await nodeServices.InvokeExport(nodeScript.FileName, "renderToString", new {
moduleName = componentModuleName,
exportName = componentExportName,
tagName = componentTagName,
requestUrl = requestUrl
});
}
}
}