public void Evaluate(EvaluateContext context) { context.For <IContent>("Content") // {Content.Slug} .Token("Slug", (content => content == null ? String.Empty : _slugService.Slugify(content))) .Token("Path", (content => { var autoroutePart = content.As <AutoroutePart>(); if (autoroutePart == null) { return(String.Empty); } var isHomePage = _homeAliasService.IsHomePage(autoroutePart); return(isHomePage ? String.Empty : autoroutePart.DisplayAlias); })) // {Content.ParentPath} .Token("ParentPath", (content => { var common = content.As <CommonPart>(); if (common == null || common.Container == null) { return(String.Empty); } var containerAutoroutePart = common.Container.As <AutoroutePart>(); if (containerAutoroutePart == null) { return(String.Empty); } if (String.IsNullOrEmpty(containerAutoroutePart.DisplayAlias)) { return(String.Empty); } var isHomePage = _homeAliasService.IsHomePage(containerAutoroutePart); return(isHomePage ? "/" : containerAutoroutePart.DisplayAlias + "/"); })); context.For <ContentTypeDefinition>("TypeDefinition") // {Content.ContentType.Slug} .Token("Slug", (ctd => _slugService.Slugify(ctd.DisplayName))); context.For <String>("Text") .Token("Slug", text => _slugService.Slugify(text)); }