public bool Transform(ContentItem item)
        {
            string text = item[Name] as string;
            if(text != null)
            {
                string detailName = Name + "_Tokens";
                int i = 0;
                var p = new Parser(new TemplateAnalyzer());
                foreach (var c in p.Parse(text).Where(c => c.Command != Parser.TextCommand))
                {
                    var dc = item.GetDetailCollection(detailName, true);
                    var cd = ContentDetail.Multi(detailName, stringValue: c.Tokens.Select(t => t.Fragment).StringJoin(), integerValue: c.Tokens.First().Index);
                    cd.EnclosingItem = item;
                    cd.EnclosingCollection = dc;

                    if (dc.Details.Count > i)
                        dc.Details[i] = cd;
                    else
                        dc.Details.Add(cd);
                    i++;
                }
                if (i > 0)
                {
                    var dc = item.GetDetailCollection(detailName, true);
                    for (int j = dc.Details.Count - 1; j >= i; j--)
                    {
                        dc.Details.RemoveAt(j);
                    }
                    return true;
                }
            }
            return false;
        }
Exemple #2
0
		protected virtual IEnumerable<Component> GetSubComponents(Parser parser, IList<Token> innerTokens)
		{
			if (ParseSubComponents)
				return parser.Parse(innerTokens.Skip(1).Take(innerTokens.Count - 2));
			
			return Component.None;
		}
 protected override IEnumerable<Component> GetSubComponents(Parser parser, IList<Token> innerTokens)
 {
     return parser.Parse(innerTokens.Skip(2).Where(c => c.Type != TokenType.NewLine));
 }