Obtenga el resultado de un controlador para generar js intellisense usando una plantilla t4

I have an action that returns a JavascriptResult that returns javascript that contains some application specific global variables.

I'd like to generate a -vsdoc.js file using a t4 template that I can reference from my other javascript files to get intellisense for this dynamically generated javascript. That way I can re-generate it on build to keep it updated. The difficulty I'm having is getting the Javascript from the controller into the t4 template. Is this possible?

A possible solution I've thought of is creating a static class that generates the javascript and calling it from the t4 template and the controller, but I haven't done so yet, and regardless of whether or not that is the best solution, I'd also like to know if it's even possible to get the results from an action into a t4 controller.

I realize this isn't the best way to do things, this is more for experimental purposes. Thanks.

preguntado el 09 de marzo de 12 a las 17:03

If you implement static class you can generate source javascript using the same template after build instead of controller action :) -

yea, this seems like the easiest solution. I am still wondering if it is possible though. -

1 Respuestas

<#@ template debug="true" hostspecific="false" language="C#" #>
<#@ output extension=".js" #>
<#@ assembly name="$(ProjectDir)bin\Web.Ux.dll" #>
<#@ assembly name="$(ProjectDir)bin\Xyz.Web.dll" #>
<#@ assembly name="System.Web.Mvc" #>
<#@ import namespace="Web.Ux.Controllers" #>
<#= JSRoutesController.GetRoutesString(null) #>

Respondido 02 Abr '12, 21:04

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.