From 00d5fe403d754e61ae32f01f6879dfc93bfa6111 Mon Sep 17 00:00:00 2001 From: Brice Figureau Date: Sun, 5 Oct 2008 18:52:20 +0200 Subject: Fix #1115 - Allow checking tags/classes from ERb templates Add to predefined variables to the ERB template space. "classes" and "tags" which provide arrays of all the defined classes and tags for a node. Signed-off-by: Brice Figureau --- lib/puppet/parser/templatewrapper.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/puppet') diff --git a/lib/puppet/parser/templatewrapper.rb b/lib/puppet/parser/templatewrapper.rb index 3b74e62d4..fc716b0fd 100644 --- a/lib/puppet/parser/templatewrapper.rb +++ b/lib/puppet/parser/templatewrapper.rb @@ -37,6 +37,16 @@ class Puppet::Parser::TemplateWrapper end end + # Allow templates to access the defined classes + def classes + return scope.catalog.classes + end + + # Allow templates to access the defined tags + def tags + return scope.catalog.tags + end + # Ruby treats variables like methods, so we used to expose variables # within scope to the ERB code via method_missing. As per RedMine #1427, # though, this means that conflicts between methods in our inheritance -- cgit