{"action":"closed","issue":{"url":"https://api.github.com/repos/Antaris/RazorEngine/issues/329","labels_url":"https://api.github.com/repos/Antaris/RazorEngine/issues/329/labels{/name}","comments_url":"https://api.github.com/repos/Antaris/RazorEngine/issues/329/comments","events_url":"https://api.github.com/repos/Antaris/RazorEngine/issues/329/events","html_url":"https://github.com/Antaris/RazorEngine/issues/329","id":110399914,"number":329,"title":"Extending the template Syntax doesn't work in loops","user":{"login":"Trollier","id":9343333,"avatar_url":"https://avatars.githubusercontent.com/u/9343333?v=3","gravatar_id":"","url":"https://api.github.com/users/Trollier","html_url":"https://github.com/Trollier","followers_url":"https://api.github.com/users/Trollier/followers","following_url":"https://api.github.com/users/Trollier/following{/other_user}","gists_url":"https://api.github.com/users/Trollier/gists{/gist_id}","starred_url":"https://api.github.com/users/Trollier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Trollier/subscriptions","organizations_url":"https://api.github.com/users/Trollier/orgs","repos_url":"https://api.github.com/users/Trollier/repos","events_url":"https://api.github.com/users/Trollier/events{/privacy}","received_events_url":"https://api.github.com/users/Trollier/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Antaris/RazorEngine/labels/need-info","name":"need-info","color":"5319e7"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-08T08:45:42Z","updated_at":"2015-10-12T23:17:32Z","closed_at":"2015-10-12T23:17:32Z","body":"Hello,\r\n\r\nI extended the syntax in order to implement some customed features.\r\n\r\nMyHtmlHelper class:\r\n<code>\r\n public IEncodedString PascalName(string name)\r\n       {\r\n           name+= \"Mister\";\r\n            return new RawString(name);\r\n       } \r\n</code>\r\n\r\nHtmlSupportTemplateBase class:\r\n<code>\r\n    public class HtmlSupportTemplateBase <T> : TemplateBase<T>\r\n    {\r\n        public HtmlSupportTemplateBase()\r\n        {\r\n            Html = new MyHtmlHelper();\r\n        }\r\n\r\n        public MyHtmlHelper Html { get; set; }\r\n    }\r\n</code>\r\n\r\nThe implementation:\r\n<code>\r\n            var config = new TemplateServiceConfiguration();\r\n            config.BaseTemplateType = typeof(HtmlSupportTemplateBase<>);\r\n            using (var service = RazorEngineService.Create(config))\r\n            {\r\n                var codeTypeListContent = Generator.Shared.Library.Deserialize(_data, typeof(CodeTypesContent)) as CodeTypesContent;\r\n                var codeTypeModel = new CodeTypeModel { CodeTypeLists = codeTypeListContent.CodeType };\r\n                string template = \"salut\";\r\n                string generatedCode = service.RunCompile(template, \"htmlRawTemplate\", null, codeTypeModel);\r\n                string outputFile = \"C:\\\\polo.txt\";\r\n                WriteTextToFile(outputFile, generatedCode);\r\n                return new[] { outputFile };\r\n            }\r\n</code>\r\n\r\nThe template : \r\n<code>\r\n@foreach( var person in Model.personsEnumerable){\r\n@:   @Html.PascalName(person.nom)\r\n}\r\n</code>\r\n\r\nThe issue is that when I use the extension outside the loop t works but when using it in the foreach loop it doesn't work and raise an exception \"A first chance exception of type 'System.ArgumentException' occurred in RazorEngine.dll\".\r\n\r\nThank you."}}