<NME> Environment.swift
<BEF> ADDFILE
<MSG> Refactor stencil swift extensions registration for easier use with an existing `Extension`. (#16)


<DFF> @@ -0,0 +1,32 @@
+//
+// StencilSwiftKit
+// Copyright (c) 2017 SwiftGen
+// MIT Licence
+//
+
+import Stencil
+
+public extension Extension {
+  public func registerStencilSwiftExtensions() {
+    registerTag("set", parser: SetNode.parse)
+    registerTag("macro", parser: MacroNode.parse)
+    registerTag("call", parser: CallNode.parse)
+    registerFilter("swiftIdentifier", filter: StringFilters.stringToSwiftIdentifier)
+    registerFilter("join", filter: ArrayFilters.join)
+    registerFilter("lowerFirstWord", filter: StringFilters.lowerFirstWord)
+    registerFilter("snakeToCamelCase", filter: StringFilters.snakeToCamelCase)
+    registerFilter("snakeToCamelCaseNoPrefix", filter: StringFilters.snakeToCamelCaseNoPrefix)
+    registerFilter("titlecase", filter: StringFilters.titlecase)
+    registerFilter("hexToInt", filter: NumFilters.hexToInt)
+    registerFilter("int255toFloat", filter: NumFilters.int255toFloat)
+    registerFilter("percent", filter: NumFilters.percent)
+    registerFilter("escapeReservedKeywords", filter: StringFilters.escapeReservedKeywords)
+  }
+}
+
+public func stencilSwiftEnvironment() -> Environment {
+  let ext = Extension()
+  ext.registerStencilSwiftExtensions()
+	
+  return Environment(extensions: [ext], templateClass: StencilSwiftTemplate.self)
+}

{'commit': 'diff --git a/CHANGELOG.md b/CHANGELOG.md\nindex 1b5cc65..c6d715a 100644\n--- a/CHANGELOG.md\n+++ b/CHANGELOG.md\n@@ -13,6 +13,9 @@\n * Renamed `SwiftTemplate` to `StencilSwiftTemplate`.  \n   [David Jennes](https://github.com/djbe)\n   [#14](https://github.com/SwiftGen/StencilSwiftKit/issues/14)\n+* Refactor stencil swift extensions registration for easier use with an existing `Extension`.  \n+  [David Jennes](https://github.com/djbe)\n+  [#16](https://github.com/SwiftGen/StencilSwiftKit/issues/16)\n \n ## Before 5.0.0\n \ndiff --git a/Pods/Pods.xcodeproj/project.pbxproj b/Pods/Pods.xcodeproj/project.pbxproj\nindex c88ab60..b5299d1 100644\n--- a/Pods/Pods.xcodeproj/project.pbxproj\n+++ b/Pods/Pods.xcodeproj/project.pbxproj\n@@ -43,6 +43,7 @@\n \t\tA2B9882F7B61B783116C9FF9147D4C05 /* Pods-Tests-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = C0ABA9994C05CE2F400945671B7038BA /* Pods-Tests-dummy.m */; };\n \t\tB65CC4D6EE2210495A18E7695A3E6DC5 /* Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27AB13C581DBF4D4B41876C69872B183 /* Extension.swift */; settings = {COMPILER_FLAGS = "-w -Xanalyzer -analyzer-disable-all-checks"; }; };\n \t\tC22E1920B40D3E75EE6C1B253A0B3E91 /* IfTag.swift in Sources */ = {isa = PBXBuildFile; fileRef = D887BD539929925B9535E5136F861F20 /* IfTag.swift */; settings = {COMPILER_FLAGS = "-w -Xanalyzer -analyzer-disable-all-checks"; }; };\n+\t\tDD426D511E3B8E9B007D843B /* Environment.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD426D4F1E3B8E90007D843B /* Environment.swift */; };\n \t\tE436943415A371D33CD28BF20935A2F9 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2497E0C37C035DB8276C0C7335E3FC93 /* Cocoa.framework */; };\n \t\tF83DF009352A70B747BDA63DBF87103F /* ForTag.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CCB7B571DD30214319D05B2A2D01268 /* ForTag.swift */; settings = {COMPILER_FLAGS = "-w -Xanalyzer -analyzer-disable-all-checks"; }; };\n \t\tF93EC375CD4D233014C44DBDE515C6D2 /* Lexer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31A007C042C580A003C9B6DB5AD1B534 /* Lexer.swift */; settings = {COMPILER_FLAGS = "-w -Xanalyzer -analyzer-disable-all-checks"; }; };\n@@ -158,6 +159,7 @@\n \t\tD6C2D28B3980163C3F38852C8437E5C2 /* Stencil.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = Stencil.modulemap; sourceTree = "<group>"; };\n \t\tD887BD539929925B9535E5136F861F20 /* IfTag.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = IfTag.swift; path = Sources/IfTag.swift; sourceTree = "<group>"; };\n \t\tE09480DB5774EB9FBBAE030F88F5BCC3 /* StencilSwiftTemplate.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = StencilSwiftTemplate.swift; sourceTree = "<group>"; };\n+\t\tDD426D4F1E3B8E90007D843B /* Environment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Environment.swift; sourceTree = "<group>"; };\n /* End PBXFileReference section */\n \n /* Begin PBXFrameworksBuildPhase section */\n@@ -212,6 +214,7 @@\n \t\t\tisa = PBXGroup;\n \t\t\tchildren = (\n \t\t\t\t95F48C2804B8C05C9EE9EB78ACC7C2E5 /* CallNode.swift */,\n+\t\t\t\tDD426D4F1E3B8E90007D843B /* Environment.swift */,\n \t\t\t\tB9C2D0FB00398A5111567EEFD1CCB01B /* Filters.swift */,\n \t\t\t\tA03EA653264F980DD920923E3D631E27 /* SetNode.swift */,\n \t\t\t\tE09480DB5774EB9FBBAE030F88F5BCC3 /* StencilSwiftTemplate.swift */,\n@@ -569,6 +572,7 @@\n \t\t\tfiles = (\n \t\t\t\t3BFB5571230E11FC87F99FE4926A252E /* CallNode.swift in Sources */,\n \t\t\t\t15F029613D94C5AAA46B6928D42D4349 /* Filters.swift in Sources */,\n+\t\t\t\tDD426D511E3B8E9B007D843B /* Environment.swift in Sources */,\n \t\t\t\tA082AAC03E6892EC107B7421BC93838D /* SetNode.swift in Sources */,\n \t\t\t\t59F231D22411C3AA93D3D9B9D9E555F5 /* StencilSwiftKit-dummy.m in Sources */,\n \t\t\t\t02A898432BFB56500E31943EA2E63D91 /* SwiftIdentifier.swift in Sources */,\ndiff --git a/Sources/Environment.swift b/Sources/Environment.swift\nnew file mode 100644\nindex 0000000..f7026ff\n--- /dev/null\n+++ b/Sources/Environment.swift\n@@ -0,0 +1,32 @@\n+//\n+// StencilSwiftKit\n+// Copyright (c) 2017 SwiftGen\n+// MIT Licence\n+//\n+\n+import Stencil\n+\n+public extension Extension {\n+  public func registerStencilSwiftExtensions() {\n+    registerTag("set", parser: SetNode.parse)\n+    registerTag("macro", parser: MacroNode.parse)\n+    registerTag("call", parser: CallNode.parse)\n+    registerFilter("swiftIdentifier", filter: StringFilters.stringToSwiftIdentifier)\n+    registerFilter("join", filter: ArrayFilters.join)\n+    registerFilter("lowerFirstWord", filter: StringFilters.lowerFirstWord)\n+    registerFilter("snakeToCamelCase", filter: StringFilters.snakeToCamelCase)\n+    registerFilter("snakeToCamelCaseNoPrefix", filter: StringFilters.snakeToCamelCaseNoPrefix)\n+    registerFilter("titlecase", filter: StringFilters.titlecase)\n+    registerFilter("hexToInt", filter: NumFilters.hexToInt)\n+    registerFilter("int255toFloat", filter: NumFilters.int255toFloat)\n+    registerFilter("percent", filter: NumFilters.percent)\n+    registerFilter("escapeReservedKeywords", filter: StringFilters.escapeReservedKeywords)\n+  }\n+}\n+\n+public func stencilSwiftEnvironment() -> Environment {\n+  let ext = Extension()\n+  ext.registerStencilSwiftExtensions()\n+\t\n+  return Environment(extensions: [ext], templateClass: StencilSwiftTemplate.self)\n+}\ndiff --git a/Sources/StencilSwiftTemplate.swift b/Sources/StencilSwiftTemplate.swift\nindex af644e9..738b8b1 100644\n--- a/Sources/StencilSwiftTemplate.swift\n+++ b/Sources/StencilSwiftTemplate.swift\n@@ -40,26 +40,3 @@ open class StencilSwiftTemplate: Template {\n     return unmarkedNewlines\n   }\n }\n-\n-// Create StencilSwiftKit-specific namespace including custom tags & filters\n-func stencilSwiftExtension() -> Extension {\n-  let namespace = Extension()\n-  namespace.registerTag("set", parser: SetNode.parse)\n-  namespace.registerTag("macro", parser: MacroNode.parse)\n-  namespace.registerTag("call", parser: CallNode.parse)\n-  namespace.registerFilter("swiftIdentifier", filter: StringFilters.stringToSwiftIdentifier)\n-  namespace.registerFilter("join", filter: ArrayFilters.join)\n-  namespace.registerFilter("lowerFirstWord", filter: StringFilters.lowerFirstWord)\n-  namespace.registerFilter("snakeToCamelCase", filter: StringFilters.snakeToCamelCase)\n-  namespace.registerFilter("snakeToCamelCaseNoPrefix", filter: StringFilters.snakeToCamelCaseNoPrefix)\n-  namespace.registerFilter("titlecase", filter: StringFilters.titlecase)\n-  namespace.registerFilter("hexToInt", filter: NumFilters.hexToInt)\n-  namespace.registerFilter("int255toFloat", filter: NumFilters.int255toFloat)\n-  namespace.registerFilter("percent", filter: NumFilters.percent)\n-  namespace.registerFilter("escapeReservedKeywords", filter: StringFilters.escapeReservedKeywords)\n-  return namespace\n-}\n-\n-public func stencilSwiftEnvironment() -> Environment {\n-  return Environment(extensions: [stencilSwiftExtension()], templateClass: StencilSwiftTemplate.self)\n-}\n', 'commit_subject': 'Refactor stencil swift extensions registration for easier use with an existing `Extension`. (#16)', 'repo_name': 'SwiftGen/StencilSwiftKit', 'committer': {'name': 'AliSoftware', 'email': '77cccf0d7a72ee0036f6f1a239d5c47ee8799014@halligon.net', 'time_sec': '1485614412', 'tz_offset': '60', 'date': {'seconds': '1485614412'}}, 'commit_tree': 'e7445d5b40c8f2d08bdbbcced4be0b20930ea9fc', 'commit_message': 'Refactor stencil swift extensions registration for easier use with an existing `Extension`. (#16)\n\n', 'language_name': 'Shell', 'license': 'mit', 'hunks': '@@ -0,0 +1,32 @@\n+//\n+// StencilSwiftKit\n+// Copyright (c) 2017 SwiftGen\n+// MIT Licence\n+//\n+\n+import Stencil\n+\n+public extension Extension {\n+  public func registerStencilSwiftExtensions() {\n+    registerTag("set", parser: SetNode.parse)\n+    registerTag("macro", parser: MacroNode.parse)\n+    registerTag("call", parser: CallNode.parse)\n+    registerFilter("swiftIdentifier", filter: StringFilters.stringToSwiftIdentifier)\n+    registerFilter("join", filter: ArrayFilters.join)\n+    registerFilter("lowerFirstWord", filter: StringFilters.lowerFirstWord)\n+    registerFilter("snakeToCamelCase", filter: StringFilters.snakeToCamelCase)\n+    registerFilter("snakeToCamelCaseNoPrefix", filter: StringFilters.snakeToCamelCaseNoPrefix)\n+    registerFilter("titlecase", filter: StringFilters.titlecase)\n+    registerFilter("hexToInt", filter: NumFilters.hexToInt)\n+    registerFilter("int255toFloat", filter: NumFilters.int255toFloat)\n+    registerFilter("percent", filter: NumFilters.percent)\n+    registerFilter("escapeReservedKeywords", filter: StringFilters.escapeReservedKeywords)\n+  }\n+}\n+\n+public func stencilSwiftEnvironment() -> Environment {\n+  let ext = Extension()\n+  ext.registerStencilSwiftExtensions()\n+\t\n+  return Environment(extensions: [ext], templateClass: StencilSwiftTemplate.self)\n+}\n', 'addition_count': 32, 'deletion_count': 0, 'src_file': '/dev/null', 'tgt_file': 'b/Sources/Environment.swift', 'file_extension': '.swift', 'before_file': 'ADDFILE', 'message': 'Refactor stencil swift extensions registration for easier use with an existing `Extension`. (#16)\n\n', 'author_name': 'AliSoftware', 'lang': 'swift'}