Skip to content

A Ruby Gem which will read a directory of flat files and present them as a single javascript hash/object. Useful for bringing in lots of application resources in a single transfer.

Notifications You must be signed in to change notification settings

dansimco/FilesToJs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#FilesToJs

FilesToJs will take a directory of text files and formats them as string values in a global javascript object. An advantage of this is the ability to use the same directory of templates for both back end and front end rendering, and have all your templates in a single compressed transfer.

Mustache Template example:

template_joiner = TemplatesToJs.new({
  :template_dir    => 'templates',  #Defaults to "templates"
  :template_format => 'mustache',   #Defaults to "*"
  :js_object_name  => 'templates',  #Defaults to "files"
  :output          => 'output/mytemplates.js'  #Path to write .js file, Defaults to false
})
template_joiner.write_js
puts template_joiner.js

Returns (javascript)

files = {
    'file 1': 'file contents',
    'file 2': 'file 2 contents',
}

About

A Ruby Gem which will read a directory of flat files and present them as a single javascript hash/object. Useful for bringing in lots of application resources in a single transfer.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages