Esempio n. 1
0
        public override void EnterTemplateDecl(HorseshoeParser.TemplateDeclContext context)
        {
            if (m_inModule)
            {
                m_writer.Write("export ");
            }

            if (context.name == null)
            {
                throw new Exception("No name specified for template.");
            }

            m_writer.WriteLine("module {0} {{", context.name.GetText());
            PushIndent();
            if (context.contextTypeName == null)
            {
                m_writer.WriteLine("export function render() : string {");
                m_hasDataContext = false;
            }
            else
            {
                m_writer.WriteLine("export function render({0} : {1}) : string {{", VAR_DataContext, context.contextTypeName.GetText());
                m_hasDataContext = true;
            }
            PushIndent();
            m_writer.WriteLine("var {0} : string = '';", VAR_TemplateResult);
            m_symbols.PushScope(context);
            m_invertTrim = context.invertTrim != null;
            m_trimLeadingWhitespaceFromBody = context.openTrimEnd != null;
        }
Esempio n. 2
0
        public override void ExitTemplateDecl(HorseshoeParser.TemplateDeclContext context)
        {
            FlushBuffer(context.closeTrimStart != null);
            m_writer.WriteLine("return {0};", VAR_TemplateResult);
            PopIndent();
            m_writer.WriteLine("}");
            PopIndent();
            m_writer.WriteLine("}");

            m_symbols.PopScope();
        }