예제 #1
0
        public string CompileSass(string input, SassMode mode)
        {
            var srs = new ScriptRuntimeSetup()
            {
                HostType = typeof(ResourceAwareScriptHost)
            };

            srs.AddRubySetup();
            var runtime = Ruby.CreateRuntime(srs);

            var engine = runtime.GetRubyEngine();

            engine.SetSearchPaths(new List <string> {
                @"R:\lib\ironruby", @"R:\lib\ruby\1.9.1"
            });

            var source = engine.CreateScriptSourceFromString(Utility.ResourceAsString("SquishIt.Sass.lib.sass_in_one.rb"), SourceCodeKind.File);
            var scope  = engine.CreateScope();

            source.Execute(scope);

            dynamic sassMode = mode == SassMode.Sass
                                   ? engine.Execute("{:syntax => :sass}")
                                   : engine.Execute("{:syntax => :scss}");

            var sassEngine = scope.Engine.Runtime.Globals.GetVariable("Sass");

            return((string)sassEngine.compile(input, sassMode));
        }
예제 #2
0
        public string CompileSass(string input, string fileName)
        {
            SassMode sassMode = SassMode.Scss;

            if (Regex.IsMatch(fileName, @"\.sass$"))
            {
                sassMode = SassMode.Sass;
            }

            return(CompileSass(input, sassMode));
        }
예제 #3
0
        public string CompileSass(string input, SassMode mode, string location, int precision = 5)
        {
            var compiler = new LibSass.Compiler.SassCompiler(new SassOptions
            {
                InputPath             = location,
                Data                  = input,
                OutputStyle           = SassOutputStyle.Nested,
                IncludeSourceComments = false,
                Precision             = precision,
                IsIndentedSyntax      = mode == SassMode.Sass
            });

            var result = compiler.Compile();

            if (!string.IsNullOrEmpty(result.ErrorMessage))
            {
                throw new InvalidOperationException(string.Format("Sass compilation failed ({0})", result.ErrorMessage));
            }

            return(result.Output);
        }
예제 #4
0
        public string CompileSass(string input, SassMode mode)
        {
            var srs = new ScriptRuntimeSetup() { HostType = typeof(ResourceAwareScriptHost) };
            srs.AddRubySetup();
            var runtime = Ruby.CreateRuntime(srs);

            var engine = runtime.GetRubyEngine();

            engine.SetSearchPaths(new List<string> { @"R:\lib\ironruby", @"R:\lib\ruby\1.9.1" });

            var source = engine.CreateScriptSourceFromString(Utility.ResourceAsString("SquishIt.Sass.lib.sass_in_one.rb"), SourceCodeKind.File);
            var scope = engine.CreateScope();
            source.Execute(scope);

            dynamic sassMode = mode == SassMode.Sass
                                   ? engine.Execute("{:syntax => :sass}")
                                   : engine.Execute("{:syntax => :scss}");

            var sassEngine = scope.Engine.Runtime.Globals.GetVariable("Sass");

            return (string) sassEngine.compile(input, sassMode);
        }
예제 #5
0
        public string CompileSass(string input, SassMode mode, string location)
        {
            var processedInput = mode == SassMode.Scss ? input : ConvertToScss(input);

            return(_compiler.Compile(processedInput, OutputStyle.Nested, SourceCommentsMode.None, new[] { location }));
        }
예제 #6
0
 public string CompileSass(string input, SassMode mode, string location, int precision = 5)
 {
     var processedInput = mode == SassMode.Scss ? input : ConvertToScss(input);
     return _compiler.Compile(processedInput, OutputStyle.Nested, SourceCommentsMode.None, precision, new[] { location });
 }