public override void Execute(ContentTransformState state)
        {
            // Support 404, not just 500
            if (state.RootPath == null)
            {
                return;
            }

            var fileSource = FindFileFromRoot(state.RootPath);

            if (fileSource == null)
            {
                return;
            }

            string result        = null;
            var    accessedFiles = new List <string>();

            using (var compiler = _compilerPool.GetInstance()) {
                result = compiler.Compile(fileSource, accessedFiles);
            }

            if (result != null)
            {
                state.ReplaceContent(new ContentResult()
                {
                    Content  = result,
                    MimeType = MimeType,
                    CacheInvalidationFileList = accessedFiles,
                });
            }
        }
Exemple #2
0
        protected virtual void Execute(ContentTransformState state, params object[] args)
        {
            // If input is empty or the wrong type, do nothing
            if (state.Content == null || state.MimeType != InputMimeType)
            {
                return;
            }

            string result = null;

            using (var compiler = _jsCompilerProvider.GetInstance()) {
                result = compiler.Compile(state.Content, args);
            }

            if (result != null)
            {
                state.ReplaceContent(new ContentResult()
                {
                    Content  = result,
                    MimeType = OutputMimeType,
                });
            }
        }