Exemple #1
0
        public virtual CompiledTemplate DefineTemplate(string templateName,
                                                       IToken nameT,
                                                       List <FormalArgument> args,
                                                       string template,
                                                       IToken templateToken)
        {
            if (templateName == null || templateName.Length == 0)
            {
                throw new ArgumentException("empty template name");
            }
            if (templateName.IndexOf('.') >= 0)
            {
                throw new ArgumentException("cannot have '.' in template names");
            }

            template = Utility.TrimOneStartingNewline(template);
            template = Utility.TrimOneTrailingNewline(template);
            // compile, passing in templateName as enclosing name for any embedded regions
            CompiledTemplate code = Compile(FileName, templateName, args, template, templateToken);

            code.name = templateName;
            RawDefineTemplate(templateName, code, nameT);
            code.DefineArgumentDefaultValueTemplates(this);
            code.DefineImplicitlyDefinedTemplates(this); // define any anonymous subtemplates

            return(code);
        }
Exemple #2
0
 public Template(TemplateGroup group, string template)
 {
     groupThatCreatedThisInstance = group;
     impl = groupThatCreatedThisInstance.Compile(group.FileName, null,
                                                 null, template, null);
     impl.hasFormalArgs = false;
     impl.name          = UnknownName;
     impl.DefineImplicitlyDefinedTemplates(groupThatCreatedThisInstance);
 }
Exemple #3
0
        public Template(TemplateGroup group, string template)
        {
            if (group == null)
                throw new ArgumentNullException("group");

            groupThatCreatedThisInstance = group;
            impl = groupThatCreatedThisInstance.Compile(group.FileName, null,
                                                        null, template, null);
            impl.HasFormalArgs = false;
            impl.Name = UnknownName;
            impl.DefineImplicitlyDefinedTemplates(groupThatCreatedThisInstance);
        }
Exemple #4
0
        public virtual CompiledTemplate DefineRegion(string enclosingTemplateName, IToken regionT, string template, IToken templateToken)
        {
            string name = regionT.Text;

            template = Utility.TrimOneStartingNewline(template);
            template = Utility.TrimOneTrailingNewline(template);
            CompiledTemplate code    = Compile(FileName, enclosingTemplateName, null, template, regionT);
            string           mangled = GetMangledRegionName(enclosingTemplateName, name);

            if (LookupTemplate(mangled) == null)
            {
                ErrorManager.CompiletimeError(ErrorType.NO_SUCH_REGION, null, regionT, enclosingTemplateName, name);
                return(new CompiledTemplate());
            }

            code.name          = mangled;
            code.isRegion      = true;
            code.regionDefType = Template.RegionType.Explicit;

            RawDefineTemplate(mangled, code, regionT);
            code.DefineArgumentDefaultValueTemplates(this);
            code.DefineImplicitlyDefinedTemplates(this); // define any anonymous subtemplates
            return(code);
        }