Example #1
0
        /// <summary>
        /// Compiles a *.js.html file into JavaScript.
        /// </summary>
        /// <param name="jsHtmlFile">The input html file.</param>
        /// <param name="outputJSFile">The output javascript file.</param>
        protected override void CompileJsHtml(string jsHtmlFile, string outputJSFile)
        {
            if (jsHtmlFile == null)
            {
                throw new ArgumentNullException("jsHtmlFile");
            }
            else if (jsHtmlFile == string.Empty)
            {
                throw new ArgumentOutOfRangeException("jsHtmlFile", "Value cannot be empty.");
            }
            if (!File.Exists(jsHtmlFile))
            {
                throw new FileNotFoundException("Unable to locate the .js.html file.", jsHtmlFile);
            }
            // read all the html in
            var html = File.ReadAllText(jsHtmlFile);

            // create the converter
            var converter = new HtmlToJavaScript.HtmlConverter();

            // get the name of the html in javascript
            var name = Path.GetFileName(jsHtmlFile).ToLower();

            // convert the html to js
            var js = converter.ToJavaScript(name, html);

            // write the js back to the output file
            File.WriteAllText(outputJSFile, js);
        }
Example #2
0
        /// <summary>
        /// Compiles a *.js.html file into JavaScript.
        /// </summary>
        /// <param name="jsHtmlFile">The input html file.</param>
        /// <param name="outputJSFile">The output javascript file.</param>
        protected override void CompileJsHtml(string jsHtmlFile, string outputJSFile)
        {
            if (jsHtmlFile == null)
            {
                throw new ArgumentNullException("jsHtmlFile");
            }
            else if (jsHtmlFile == string.Empty)
            {
                throw new ArgumentOutOfRangeException("jsHtmlFile", "Value cannot be empty.");
            }
            if (!File.Exists(jsHtmlFile))
            {
                throw new FileNotFoundException("Unable to locate the .js.html file.", jsHtmlFile);
            }
            // read all the html in
            var html = File.ReadAllText(jsHtmlFile);

            // create the converter
            var converter = new HtmlToJavaScript.HtmlConverter();

            // get the name of the html in javascript
            var name = Path.GetFileName(jsHtmlFile).ToLower();

            // convert the html to js
            var js = converter.ToJavaScript(name, html);

            // write the js back to the output file
            File.WriteAllText(outputJSFile, js);
        }