public CoffeeScriptHttpHandler() { if (coffeeScriptEngine == null) { coffeeScriptEngine = new CoffeeScriptEngine(); } }
public override void Process(BundleResponse bundle) { var compiler = new CoffeeScriptEngine(); bundle.Content = compiler.Compile(bundle.Content); base.Process(bundle); }
public string Compile(string input) { if (FileSystem.Unix) { throw new NotSupportedException("Coffeescript not yet supported for mono."); } CoffeeScriptEngine.SetGlobalValue("Source", input); // Errors go from here straight on to the rendered page; // we don't want to hide them because they provide valuable feedback // on the location of the error var result = CoffeeScriptEngine.Evaluate <string>("CoffeeScript.compile(Source, {bare: false})"); return(result); }
public void Process(BundleContext context, BundleResponse response) { var coffeeEngine = new CoffeeScriptEngine(); var compiledCoffeeScript = string.Empty; foreach (var file in response.Files) { using (var sr = new StreamReader(file.FullName)) { compiledCoffeeScript += coffeeEngine.Compile(sr.ReadToEnd()); sr.Close(); } } response.Content = compiledCoffeeScript; response.ContentType = "text/javascript"; response.Cacheability = HttpCacheability.Public; }
public CoffeeSharpCompiler() { _compiler = new CoffeeScriptEngine(); }
/// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary> /// <param name='commandName'>The name of the command to execute.</param> /// <param name='executeOption'>Describes how the command should be run.</param> /// <param name='varIn'>Parameters passed from the caller to the command handler.</param> /// <param name='varOut'>Parameters passed from the command handler to the caller.</param> /// <param name='handled'>Informs the caller if the command was handled or not.</param> public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = false; if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { if (this.App != null) { string fileToTry = string.Empty; try { if (commandName == COMMANDNAMESPACE + "." + POPUP_MENU_NAME_MINIFIER) { try { ProjectItem projectItem = this.App.SelectedItems.Item(1).ProjectItem; if (EngineManager.IsHandledWithoutHint(projectItem.FileName())) { this.ProjectItemsEvents_ItemAdded(projectItem); } else { string path = projectItem.FileName(); string code = System.IO.File.ReadAllText(path); var settings = Settings.Instance(path); string outputExtension = settings.OutputExtensionJS; if (this.IsLessFile(path)) { code = LessEngine.TransformToCss(path, code, projectItem); outputExtension = settings.OutputExtensionCSS; } else if (this.IsCoffeeScriptFile(path)) { code = CoffeeScriptEngine.TransformToJs(path, code, projectItem); outputExtension = settings.OutputExtensionJS; } else if (this.IsSassFile(path)) { code = SassEngine.TransformToCss(path, code, projectItem); outputExtension = settings.OutputExtensionCSS; } else if (this.IsCssFile(path)) { code = CssEngine.Minify(path, code, projectItem, Xml.MinifyType.Unspecified); outputExtension = settings.OutputExtensionCSS; } else if (this.IsJsFile(path)) { code = JsEngine.Minify(path, code, projectItem, Xml.MinifyType.Unspecified, string.Empty); outputExtension = settings.OutputExtensionJS; } using (var manager = new Manager.VSProjectItemManager(this.App, projectItem)) { manager.AddFileByFileName(Utilities.GetBaseFileName(path) + outputExtension, code); } } } catch (Exception e) { this.OutputWindowWriteText(e.ToString()); } } else if (commandName == COMMANDNAMESPACE + "." + POPUP_MENU_NAME_JSHINT) { try { ProjectItem projectItem = this.App.SelectedItems.Item(1).ProjectItem; string path = projectItem.FileName(); JSHintEngine.Run(path, projectItem); } catch (Exception e) { this.OutputWindowWriteText(e.ToString()); } } else if (commandName == COMMANDNAMESPACE + "." + POPUP_MENU_NAME_CSSLINT) { try { ProjectItem projectItem = this.App.SelectedItems.Item(1).ProjectItem; string path = projectItem.FileName(); CSSLintEngine.Run(path, projectItem); } catch (Exception e) { this.OutputWindowWriteText(e.ToString()); } } else if (commandName == COMMANDNAMESPACE + "." + POPUP_MENU_NAME_TYPESCRIPT) { try { ProjectItem projectItem = this.App.SelectedItems.Item(1).ProjectItem; string path = projectItem.FileName(); TypeScriptEngine.Run(path, projectItem); } catch (Exception e) { this.OutputWindowWriteText(e.ToString()); } } } catch (Exception ex) { this.OutputWindowWriteText(string.Format("Error occured.\r\nFileName:\r\n{0}\r\nException details:\r\n{1}", fileToTry, ex)); } // try handled = true; return; } } } // Exec
public CoffeeScriptHttpHandler() { this.coffeeScriptEngine = new CoffeeScriptEngine(); }