Skip to content

FileTagger provides HTML helpers to dynamically create tags for JavaScript, CSS or other file-based elements in an ASP.NET MVC project.

License

Notifications You must be signed in to change notification settings

timgit/file-tagger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#Summary#

FileTagger provides HTML helpers to dynamically create tags for JavaScript, CSS or other file-based elements in an ASP.NET MVC project. It supports the web application root operator, the tilde (~), and several wildcard patterns for locating the files.

This was originally built for injecting revision-named JavaScript and CSS bundles from client-side build tools, such as grunt-filerev or gulp-rev. However, it could be used simply to inject tags baesd on the virtual path of the hosting application.

This run-time technique is an alternative to injection tools which write script tags at build time. Ideally, this will keep your Razor layout file free from contention and merge conflicts when working with a team of developers.

#Usage# Currently, FileTagger is an abstraction over DirectoryInfo.GetFiles(), so it only supports a limited search pattern such as asterisks and question marks.

Following are some usage examples, assuming you have a @using FileTagger directive at the top of your cshtml file.

JavaScript bundle wildcard usage (what I built this for)

@Render.Script("~/public/build/js/app_bundle*.js")

Virtual path usage - single file

@Render.Link("~/Content/bootstrap.css")

Wildcard usage - multiple files

@Render.Links("~/Content/bootstrap-theme*.css")

Single character wildcard usage with question marks

@Render.Script("~/Scripts/jquery-2.?.?.js")

#Installation# You can either include /src/FileTagger/Render.cs into your ASP.NET MVC project directly or use the NuGet package I created to keep it as an externally versioned dependency.

If you'd like to install via NuGet package manager console:

Install-Package FileTagger

About

FileTagger provides HTML helpers to dynamically create tags for JavaScript, CSS or other file-based elements in an ASP.NET MVC project.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages