XHTML minifier
Inheritance: IMarkupMinifier
Example #1
0
        /// <summary>
        /// Creates a instance of XHTML minifier based on the settings
        /// that specified in configuration files (App.config or Web.config)
        /// </summary>
        /// <param name="settings">XHTML minification settings</param>
        /// <param name="cssMinifier">CSS minifier</param>
        /// <param name="jsMinifier">JS minifier</param>
        /// <param name="logger">logger</param>
        /// <returns>XHTML minifier</returns>
        public XhtmlMinifier CreateXhtmlMinifierInstance(XhtmlMinificationSettings settings = null,
                                                         ICssMinifier cssMinifier           = null, IJsMinifier jsMinifier = null, ILogger logger = null)
        {
            XhtmlMinificationSettings innerSettings = settings ?? GetXhtmlMinificationSettings();
            ICssMinifier innerCssMinifier           = cssMinifier ?? _wmmContext.Code.CreateDefaultCssMinifierInstance();
            IJsMinifier  innerJsMinifier            = jsMinifier ?? _wmmContext.Code.CreateDefaultJsMinifierInstance();
            ILogger      innerLogger = logger ?? _wmmContext.GetDefaultLoggerInstance();

            var xhtmlMinifier = new XhtmlMinifier(innerSettings, innerCssMinifier, innerJsMinifier, innerLogger);

            return(xhtmlMinifier);
        }
        public XhtmlMinificationViewModel Minify(XhtmlMinificationViewModel model)
        {
            string cssMinifierName = model.Settings.CssMinifierName;
            string jsMinifierName = model.Settings.JsMinifierName;

            var settings = Mapper.Map<XhtmlMinificationSettings>(model.Settings);
            ICssMinifier cssMinifier = _cssMinifierFactory.CreateMinifier(cssMinifierName);
            IJsMinifier jsMinifier = _jsMinifierFactory.CreateMinifier(jsMinifierName);

            var xhtmlMinifier = new XhtmlMinifier(settings, cssMinifier, jsMinifier);
            var result = xhtmlMinifier.Minify(model.SourceCode, true);

            model.Result = Mapper.Map<MarkupMinificationResultViewModel>(result);

            return model;
        }
Example #3
0
        public IEnumerable<IDocument> Execute(IReadOnlyList<IDocument> inputs, IExecutionContext context)
        {
            XhtmlMinifier minifier = new XhtmlMinifier(_minificationSettings);

            return Minify(inputs, context, minifier.Minify, "XHTML");
        }