-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
305 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> | ||
<metadata> | ||
<id>Angular-Template-Bundler</id> | ||
<version>0.0.3.0</version> | ||
<title>Angular Template Bundler</title> | ||
<authors>William Wood</authors> | ||
<owners>wwood</owners> | ||
<licenseUrl>https://raw.githubusercontent.com/wmwood/Angular-Template-Bundler/master/LICENSE.md</licenseUrl> | ||
<projectUrl>https://github.com/wmwood/Angular-Template-Bundler</projectUrl> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<description>A simple ASP.NET MVC bundle that helps you combine all of your angular html templates into one file and add to your app's template cache.</description> | ||
<summary /> | ||
<copyright>2015</copyright> | ||
<language>en-US</language> | ||
<tags>angularjs templates bundling System.Web.Optimization</tags> | ||
<dependencies> | ||
<dependency id="Microsoft.AspNet.Web.Optimization" version="1.1.3" /> | ||
</dependencies> | ||
</metadata> | ||
<files> | ||
<file src="wmwood.AngularTemplateBundler\bin\Release\wmwood.AngularTemplateBundler.dll" target="lib\wmwood.AngularTemplateBundler.dll" /> | ||
</files> | ||
</package> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 William Wood | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Angular Template Bundler | ||
|
||
A simple ASP.NET MVC bundle that helps you combine all of your angular html templates into one file and add to your app's template cache. | ||
|
||
## Installation | ||
|
||
``` Powershell | ||
PM> Install-Package Angular-Template-Bundler | ||
``` | ||
[see nuget](https://www.nuget.org/packages/Angular-Template-Bundler/) | ||
|
||
## Usage | ||
|
||
#### Add this line to your BundleConfig.cs: | ||
``` C# | ||
bundles.Add(new AngularTemplateBundle("VIRTUAL_PATH", "ANGULAR_MODULE_NAME") | ||
.IncludeDirectory("PATH_TO_APP_FOLDER", "SEARCH_PATTERN", SEARCH_SUBFOLDERS)); | ||
``` | ||
|
||
An example usage would be: | ||
``` C# | ||
bundles.Add(new AngularTemplateBundle("~/bundles/app/templates", "myApp") | ||
.IncludeDirectory("~/Assets/js/app", "*.tpl.html", true)); | ||
``` | ||
|
||
#### Then, add this line to your main razor page: | ||
|
||
``` C# | ||
@Scripts.Render("~/bundles/app/templates") | ||
``` | ||
|
||
## License | ||
[see LICENSE.md](LICENSE.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 2013 | ||
VisualStudioVersion = 12.0.40629.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wmwood.AngularTemplateBundler", "wmwood.AngularTemplateBundler\wmwood.AngularTemplateBundler.csproj", "{5BCCD6D0-28B6-451E-918E-E2C15B2B85E7}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{5BCCD6D0-28B6-451E-918E-E2C15B2B85E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{5BCCD6D0-28B6-451E-918E-E2C15B2B85E7}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{5BCCD6D0-28B6-451E-918E-E2C15B2B85E7}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{5BCCD6D0-28B6-451E-918E-E2C15B2B85E7}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Web.Optimization; | ||
|
||
namespace wmwood.AngularTemplateBundler | ||
{ | ||
public class AngularTemplateBundle : Bundle | ||
{ | ||
public AngularTemplateBundle(string virtualPath, string moduleName) | ||
: base(virtualPath, new AngularTemplateTransform(moduleName), new JsMinify()) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System.IO; | ||
using System.Text; | ||
using System.Web; | ||
using System.Web.Optimization; | ||
|
||
namespace wmwood.AngularTemplateBundler | ||
{ | ||
public class AngularTemplateTransform : IBundleTransform | ||
{ | ||
private const string ContentType = "text/javascript"; | ||
private const string FooterText = "}])})()"; | ||
private readonly string _moduleName; | ||
|
||
public AngularTemplateTransform(string moduleName) | ||
{ | ||
_moduleName = moduleName; | ||
} | ||
|
||
public void Process(BundleContext context, BundleResponse response) | ||
{ | ||
var responseContent = new StringBuilder(); | ||
responseContent.Append(GetHeaderText()); | ||
|
||
foreach (var bundleFile in response.Files) | ||
{ | ||
responseContent.Append(GetBundleText(bundleFile)); | ||
} | ||
|
||
responseContent.Append(FooterText); | ||
|
||
FormatResponse(response); | ||
response.Content = responseContent.ToString(); | ||
} | ||
|
||
private string GetHeaderText() | ||
{ | ||
return string.Format("(function() {{ \"use strict\"; angular.module(\"{0}\").run([\"$templateCache\", function($templateCache) {{", _moduleName); | ||
} | ||
|
||
private static string GetBundleText(BundleFile bundleFile) | ||
{ | ||
return string.Format("$templateCache.put(\"{0}\", \"{1}\");", GetTemplatePath(bundleFile), GetJavascriptEncodedContent(bundleFile)); | ||
} | ||
|
||
private static string GetTemplatePath(BundleFile bundleFile) | ||
{ | ||
return VirtualPathUtility.ToAbsolute(bundleFile.IncludedVirtualPath); | ||
} | ||
|
||
private static string GetJavascriptEncodedContent(BundleFile bundleFile) | ||
{ | ||
using (var streamReader = new StreamReader(BundleTable.VirtualPathProvider.GetFile(bundleFile.IncludedVirtualPath).Open())) | ||
{ | ||
return HttpUtility.JavaScriptStringEncode(streamReader.ReadToEnd().Trim()); | ||
} | ||
} | ||
|
||
private static void FormatResponse(BundleResponse response) | ||
{ | ||
response.Files = new BundleFile[] {}; | ||
response.ContentType = ContentType; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("wmwood.AngularTemplateBundler")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("William Wood")] | ||
[assembly: AssemblyProduct("wmwood.AngularTemplateBundler")] | ||
[assembly: AssemblyCopyright("Copyright © 2015")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("b7e695d1-0a83-4527-ac63-6fd214d39098")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("0.0.3.0")] | ||
[assembly: AssemblyFileVersion("0.0.3.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<runtime> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
</runtime> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Antlr" version="3.4.1.9004" targetFramework="net40" /> | ||
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net40" /> | ||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net40" /> | ||
<package id="Newtonsoft.Json" version="5.0.4" targetFramework="net40" /> | ||
<package id="WebGrease" version="1.5.2" targetFramework="net40" /> | ||
</packages> |
75 changes: 75 additions & 0 deletions
75
wmwood.AngularTemplateBundler/wmwood.AngularTemplateBundler.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{5BCCD6D0-28B6-451E-918E-E2C15B2B85E7}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>wmwood.AngularTemplateBundler</RootNamespace> | ||
<AssemblyName>wmwood.AngularTemplateBundler</AssemblyName> | ||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<WebGreaseLibPath>..\packages\WebGrease.1.5.2\lib</WebGreaseLibPath> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Antlr3.Runtime, Version=3.4.1.9004, Culture=neutral, PublicKeyToken=eb42632606e9261f, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Antlr.3.4.1.9004\lib\Antlr3.Runtime.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Newtonsoft.Json.5.0.4\lib\net40\Newtonsoft.Json.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Web" /> | ||
<Reference Include="System.Web.Optimization, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="WebGrease, Version=1.5.2.14234, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\WebGrease.1.5.2\lib\WebGrease.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="AngularTemplateBundle.cs" /> | ||
<Compile Include="AngularTemplateTransform.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="app.config" /> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |