Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
28 lines (23 sloc) 1.01 KB
/// NOTE: Maybe this should be an extra module?
/// Contains basic templating functions. Used in other helpers.
module Fake.IO.Templates
/// Loads all templates (lazy - line by line!)
let load seq = (fun fileName -> fileName, fileName) seq
/// Replaces a bunch of the keywords in all files (lazy - line by line!)
let replaceKeywords replacements = (fun (fileName, file) ->
file |> (fun (line : string) ->
let mutable sb = new System.Text.StringBuilder(line)
for (k : string, r : string) in replacements do
sb <- sb.Replace(k, r)
/// Saves all files (lazy - file by file!)
let saveFiles = Seq.iter (fun (fileName, file) -> File.write false fileName (Seq.toList file))
/// Replaces the templates with the given replacements
let replaceInFiles replacements files =
|> load
|> replaceKeywords replacements
|> saveFiles
You can’t perform that action at this time.