Skip to content

Commit

Permalink
template resource now writes to a file
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Bombadil committed Oct 10, 2012
1 parent 4ae4123 commit e50d1b9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/tmp
4 changes: 4 additions & 0 deletions lib/_attributes
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,8 @@ attr_accessor mode
attr_accessor owner
attr_accessor group
attr_accessor path
attr_accessor create_if_missing
attr_accessor backup 5
attr_accessor cookbook
attr_accessor sauce
attr_accessor variables
6 changes: 5 additions & 1 deletion lib/_template
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ function do_template_create {
local _dollar='$'
local pth_source="${_poop_sauce}"

eval "cat <<EOF
local tmp_template="$(mktemp -t XXXXXXXXX)"
eval "cat > $tmp_template <<EOF
$(cat "${pth_source}" | perl -pe 's{\$\{(\w+)\}}{!!!/$1/!!!}g;
s{\$}{\${_dollar}}g;
s{!!!/(\w+)/!!!}{\${$1}}g;')
EOF"

install -v $(install_options)"$tmp_template" "${_poop_path}"
rm -f "$tmp_template"
}
5 changes: 4 additions & 1 deletion recipes/meh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ directory "meh"
action delete
end

directory "tmp"
end

name="David"
template "hello.txt"
template "tmp/hello.txt"
sauce "templates/feh"
end

0 comments on commit e50d1b9

Please sign in to comment.