Repository: sunng87/handlebars-rust
Pull request #310 (2020-01-23 09:46:26)

Rename directive to decorator
This patch renames `Directive`s to handlebars' standard name `Decorator`. 


Patch:
diff --git a/src/directives/inline.rs b/src/decorators/inline.rs
similarity index 75%
rename from src/directives/inline.rs
rename to src/decorators/inline.rs
index 579b7c2..0258a65 100644
--- a/src/directives/inline.rs
+++ b/src/decorators/inline.rs
@@ -1,15 +1,15 @@
 use crate::context::Context;
-use crate::directives::{DirectiveDef, DirectiveResult};
+use crate::decorators::{DecoratorDef, DecoratorResult};
 use crate::error::RenderError;
 use crate::registry::Registry;
-use crate::render::{Directive, RenderContext};
+use crate::render::{Decorator, RenderContext};
 
 #[derive(Clone, Copy)]
-pub struct InlineDirective;
+pub struct InlineDecorator;
 
-fn get_name<'reg: 'rc, 'rc>(d: &'rc Directive<'reg, 'rc>) -> Result<&'rc str, RenderError> {
+fn get_name<'reg: 'rc, 'rc>(d: &'rc Decorator<'reg, 'rc>) -> Result<&'rc str, RenderError> {
     d.param(0)
-        .ok_or_else(|| RenderError::new("Param required for directive \"inline\""))
+        .ok_or_else(|| RenderError::new("Param required for decorator \"inline\""))
         .and_then(|v| {
             v.value()
                 .as_str()
@@ -17,14 +17,14 @@ fn get_name<'reg: 'rc, 'rc>(d: &'rc Directive<'reg, 'rc>) -> Result<&'rc str, Re
         })
 }
 
-impl DirectiveDef for InlineDirective {
+impl DecoratorDef for InlineDecorator {
     fn call<'reg: 'rc, 'rc>(
         &self,
-        d: &Directive<'reg, 'rc>,
+        d: &Decorator<'reg, 'rc>,
         _: &'reg Registry,
         _: &'rc Context,
         rc: &mut RenderContext<'reg, 'rc>,
-    ) -> DirectiveResult {
+    ) -> DecoratorResult {
         let name = get_name(d)?;
 
         let template = d
@@ -36,7 +36,7 @@ impl DirectiveDef for InlineDirective {
     }
 }
 
-pub static INLINE_DIRECTIVE: InlineDirective = InlineDirective;
+pub static INLINE_DECORATOR: InlineDecorator = InlineDecorator;
 
 #[cfg(test)]
 mod test {
diff --git a/src/directives/mod.rs b/src/decorators/mod.rs
similarity index 91%
rename from src/directives/mod.rs
rename to src/decorators/mod.rs
index 97fff50..c07b4a0 100644
--- a/src/directives/mod.rs
+++ b/src/decorators/mod.rs
@@ -1,15 +1,15 @@
 use crate::context::Context;
 use crate::error::RenderError;
 use crate::registry::Registry;
-use crate::render::{Directive, RenderContext};
+use crate::render::{Decorator, RenderContext};
 
-pub use self::inline::INLINE_DIRECTIVE;
+pub use self::inline::INLINE_DECORATOR;
 
-pub type DirectiveResult = Result<(), RenderError>;
+pub type DecoratorResult = Result<(), RenderError>;
 
 /// Decorator Definition
 ///
-/// Implement this trait to define your own decorators or directives. Currently
+/// Implement this trait to define your own decorators or decorators. Currently
 /// decorator shares same definition with helper.
 ///
 /// In handlebars, it is recommended to use decorator to change context data and update helper
@@ -56,35 +56,35 @@ pub type DirectiveResult = Result<(), RenderError>;
 /// }
 /// ```
 ///
-pub trait DirectiveDef: Send + Sync {
+pub trait DecoratorDef: Send + Sync {
     fn call<'reg: 'rc, 'rc>(
         &'reg self,
-        d: &Directive<'reg, 'rc>,
+        d: &Decorator<'reg, 'rc>,
         r: &'reg Registry,
         ctx: &'rc Context,
         rc: &mut RenderContext<'reg, 'rc>,
-    ) -> DirectiveResult;
+    ) -> DecoratorResult;
 }
 
-/// implement DirectiveDef for bare function so we can use function as directive
+/// implement DecoratorDef for bare function so we can use function as decorator
 impl<
         F: Send
             + Sync
             + for<'reg, 'rc> Fn(
-                &Directive<'reg, 'rc>,
+                &Decorator<'reg, 'rc>,
                 &'reg Registry,
                 &'rc Context,
                 &mut RenderContext,
-            ) -> DirectiveResult,
-    > DirectiveDef for F
+            ) -> DecoratorResult,
+    > DecoratorDef for F
 {
     fn call<'reg: 'rc, 'rc>(
         &'reg self,
-        d: &Directive<'reg, 'rc>,
+        d: &Decorator<'reg, 'rc>,
         reg: &'reg Registry,
         ctx: &'rc Context,
         rc: &mut RenderContext,
-    ) -> DirectiveResult {
+    ) -> DecoratorResult {
         (*self)(d, reg, ctx, rc)
     }
 }
@@ -98,7 +98,7 @@ mod test {
     use crate::json::value::{as_string, to_json};
     use crate::output::Output;
     use crate::registry::Registry;
-    use crate::render::{Directive, Helper, RenderContext};
+    use crate::render::{Decorator, Helper, RenderContext};
 
     #[test]
     fn test_register_decorator() {
@@ -116,7 +116,7 @@ mod test {
         handlebars.register_decorator(
             "foo",
             Box::new(
-                |_: &Directive,
+                |_: &Decorator,
                  _: &Registry,
                  _: &Context,
                  _: &mut RenderContext|
@@ -141,7 +141,7 @@ mod test {
         handlebars.register_decorator(
             "foo",
             Box::new(
-                |_: &Directive,
+                |_: &Decorator,
                  _: &Registry,
                  ctx: &Context,
                  rc: &mut RenderContext|
@@ -169,7 +169,7 @@ mod test {
         handlebars.register_decorator(
             "bar",
             Box::new(
-                |d: &Directive,
+                |d: &Decorator,
                  _: &Registry,
                  _: &Context,
                  rc: &mut RenderContext|
@@ -247,7 +247,7 @@ mod test {
         handlebars.register_decorator(
             "foo",
             Box::new(
-                |d: &Directive,
+                |d: &Decorator,
                  _: &Registry,
                  _: &Context,
                  rc: &mut RenderContext|
@@ -284,7 +284,7 @@ mod test {
         handlebars.register_decorator(
             "bar",
             Box::new(
-                |_: &Directive,
+                |_: &Decorator,
                  _: &Registry,
                  _: &Context,
                  rc: &mut RenderContext|
diff --git a/src/error.rs b/src/error.rs
index e9b7ca5..39f0216 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -97,8 +97,8 @@ quick_error! {
             display("helper {:?} was opened, but {:?} is closing",
                 open, closed)
         }
-        MismatchingClosedDirective(open: String, closed: String) {
-            display("directive {:?} was opened, but {:?} is closing",
+        MismatchingClosedDecorator(open: String, closed: String) {
+            display("decorator {:?} was opened, but {:?} is closing",
                 open, closed)
         }
         InvalidSyntax {
diff --git a/src/grammar.pest b/src/grammar.pest
index 2b0f53a..35e5a32 100644
--- a/src/grammar.pest
+++ b/src/grammar.pest
@@ -46,7 +46,7 @@ expression = { !invert_tag ~ "{{" ~ pre_whitespace_omitter? ~
 html_expression = { "{{{" ~ pre_whitespace_omitter? ~ name ~
 pro_whitespace_omitter? ~ "}}}" }
 
-directive_expression = { "{{" ~ pre_whitespace_omitter? ~ "*" ~ exp_line ~
+decorator_expression = { "{{" ~ pre_whitespace_omitter? ~ "*" ~ exp_line ~
 pro_whitespace_omitter? ~ "}}" }
 partial_expression = { "{{" ~ pre_whitespace_omitter? ~ ">" ~ partial_exp_line
                      ~ pro_whitespace_omitter? ~ "}}" }
@@ -60,12 +60,12 @@ helper_block_end = { "{{" ~ pre_whitespace_omitter? ~ "/" ~ identifier ~
 helper_block = _{ helper_block_start ~ template ~
                   (invert_tag ~ template)? ~ helper_block_end }
 
-directive_block_start = { "{{" ~ pre_whitespace_omitter? ~ "#" ~ "*"
+decorator_block_start = { "{{" ~ pre_whitespace_omitter? ~ "#" ~ "*"
                         ~ exp_line ~ pro_whitespace_omitter? ~ "}}" }
-directive_block_end = { "{{" ~ pre_whitespace_omitter? ~ "/" ~ identifier ~
+decorator_block_end = { "{{" ~ pre_whitespace_omitter? ~ "/" ~ identifier ~
                         pro_whitespace_omitter? ~ "}}" }
-directive_block = _{ directive_block_start ~ template ~
-                     directive_block_end }
+decorator_block = _{ decorator_block_start ~ template ~
+                     decorator_block_end }
 
 partial_block_start = { "{{" ~ pre_whitespace_omitter? ~ "#" ~ ">"
                         ~ partial_exp_line ~ pro_whitespace_omitter? ~ "}}" }
@@ -90,8 +90,8 @@ template = { (
             raw_block |
             hbs_comment |
             hbs_comment_compact |
-            directive_expression |
-            directive_block |
+            decorator_expression |
+            decorator_block |
             partial_expression |
             partial_block )* }
 
diff --git a/src/grammar.rs b/src/grammar.rs
index eeaf220..66a4dad 100644
--- a/src/grammar.rs
+++ b/src/grammar.rs
@@ -293,22 +293,22 @@ fn test_path() {
 }
 
 #[test]
-fn test_directive_expression() {
+fn test_decorator_expression() {
     let s = vec!["{{* ssh}}", "{{~* ssh}}"];
     for i in s.iter() {
-        assert_rule!(Rule::directive_expression, i);
+        assert_rule!(Rule::decorator_expression, i);
     }
 }
 
 #[test]
-fn test_directive_block() {
+fn test_decorator_block() {
     let s = vec![
         "{{#* inline}}something{{/inline}}",
         "{{~#* inline}}hello{{/inline}}",
         "{{#* inline \"partialname\"}}something{{/inline}}",
     ];
     for i in s.iter() {
-        assert_rule!(Rule::directive_block, i);
+        assert_rule!(Rule::decorator_block, i);
     }
 }
 
diff --git a/src/lib.rs b/src/lib.rs
index a02f545..02fede0 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -349,14 +349,14 @@ extern crate walkdir;
 
 pub use self::block::{BlockContext, BlockParams};
 pub use self::context::Context;
-pub use self::directives::DirectiveDef as DecoratorDef;
+pub use self::decorators::DecoratorDef;
 pub use self::error::{RenderError, TemplateError, TemplateFileError, TemplateRenderError};
 pub use self::helpers::{HelperDef, HelperResult};
 pub use self::json::path::Path;
 pub use self::json::value::{to_json, JsonRender, PathAndJson, ScopedJson};
 pub use self::output::Output;
 pub use self::registry::{html_escape, no_escape, EscapeFn, Registry as Handlebars};
-pub use self::render::{Directive as Decorator, Evaluable, Helper, RenderContext, Renderable};
+pub use self::render::{Decorator, Evaluable, Helper, RenderContext, Renderable};
 pub use self::template::Template;
 
 #[doc(hidden)]
@@ -366,7 +366,7 @@ pub use self::serde_json::Value as JsonValue;
 mod macros;
 mod block;
 mod context;
-mod directives;
+mod decorators;
 mod error;
 mod grammar;
 mod helpers;
diff --git a/src/partial.rs b/src/partial.rs
index f32d99d..961e6d2 100644
--- a/src/partial.rs
+++ b/src/partial.rs
@@ -7,12 +7,12 @@ use crate::error::RenderError;
 use crate::json::path::Path;
 use crate::output::Output;
 use crate::registry::Registry;
-use crate::render::{Directive, Evaluable, RenderContext, Renderable};
+use crate::render::{Decorator, Evaluable, RenderContext, Renderable};
 use crate::template::Template;
 
 fn render_partial<'reg: 'rc, 'rc>(
     t: &'reg Template,
-    d: &Directive<'reg, 'rc>,
+    d: &Decorator<'reg, 'rc>,
     r: &'reg Registry,
     ctx: &'rc Context,
     local_rc: &mut RenderContext<'reg, 'rc>,
@@ -52,7 +52,7 @@ fn render_partial<'reg: 'rc, 'rc>(
 }
 
 pub fn expand_partial<'reg: 'rc, 'rc>(
-    d: &Directive<'reg, 'rc>,
+    d: &Decorator<'reg, 'rc>,
     r: &'reg Registry,
     ctx: &'rc Context,
     rc: &mut RenderContext<'reg, 'rc>,
diff --git a/src/registry.rs b/src/registry.rs
index 3419b67..afd40dd 100644
--- a/src/registry.rs
+++ b/src/registry.rs
@@ -7,7 +7,7 @@ use std::path::Path;
 use serde::Serialize;
 
 use crate::context::Context;
-use crate::directives::{self, DirectiveDef};
+use crate::decorators::{self, DecoratorDef};
 use crate::error::{RenderError, TemplateError, TemplateFileError, TemplateRenderError};
 use crate::helpers::{self, HelperDef};
 use crate::output::{Output, StringOutput, WriteOutput};
@@ -43,7 +43,7 @@ pub fn no_escape(data: &str) -> String {
 pub struct Registry<'reg> {
     templates: HashMap<String, Template>,
     helpers: HashMap<String, Box<dyn HelperDef + 'reg>>,
-    directives: HashMap<String, Box<dyn DirectiveDef + 'reg>>,
+    decorators: HashMap<String, Box<dyn DecoratorDef + 'reg>>,
     escape_fn: EscapeFn,
     source_map: bool,
     strict_mode: bool,
@@ -54,7 +54,7 @@ impl<'reg> Debug for Registry<'reg> {
         f.debug_struct("Handlebars")
             .field("templates", &self.templates)
             .field("helpers", &self.helpers.keys())
-            .field("directives", &self.directives.keys())
+            .field("decorators", &self.decorators.keys())
             .field("source_map", &self.source_map)
             .finish()
     }
@@ -86,7 +86,7 @@ impl<'reg> Registry<'reg> {
         let r = Registry {
             templates: HashMap::new(),
             helpers: HashMap::new(),
-            directives: HashMap::new(),
+            decorators: HashMap::new(),
             escape_fn: Box::new(html_escape),
             source_map: true,
             strict_mode: false,
@@ -114,7 +114,7 @@ impl<'reg> Registry<'reg> {
         self.register_helper("or", Box::new(helpers::helper_boolean::or));
         self.register_helper("not", Box::new(helpers::helper_boolean::not));
 
-        self.register_decorator("inline", Box::new(directives::INLINE_DIRECTIVE));
+        self.register_decorator("inline", Box::new(decorators::INLINE_DECORATOR));
         self
     }
 
@@ -272,9 +272,9 @@ impl<'reg> Registry<'reg> {
     pub fn register_decorator(
         &mut self,
         name: &str,
-        def: Box<dyn DirectiveDef + 'reg>,
-    ) -> Option<Box<dyn DirectiveDef + 'reg>> {
-        self.directives.insert(name.to_string(), def)
+        def: Box<dyn DecoratorDef + 'reg>,
+    ) -> Option<Box<dyn DecoratorDef + 'reg>> {
+        self.decorators.insert(name.to_string(), def)
     }
 
     /// Register a new *escape fn* to be used from now on by this registry.
@@ -310,9 +310,9 @@ impl<'reg> Registry<'reg> {
         self.helpers.get(name).map(|v| v.as_ref())
     }
 
-    /// Return a registered directive, aka decorator
-    pub fn get_decorator(&self, name: &str) -> Option<&(dyn DirectiveDef)> {
-        self.directives.get(name).map(|v| v.as_ref())
+    /// Return a registered decorator, aka decorator
+    pub fn get_decorator(&self, name: &str) -> Option<&(dyn DecoratorDef)> {
+        self.decorators.get(name).map(|v| v.as_ref())
     }
 
     /// Return all templates registered
diff --git a/src/render.rs b/src/render.rs
index 850ba51..040b9e0 100644
--- a/src/render.rs
+++ b/src/render.rs
@@ -17,7 +17,7 @@ use crate::partial;
 use crate::registry::Registry;
 use crate::template::TemplateElement::*;
 use crate::template::{
-    BlockParam, DirectiveTemplate, HelperTemplate, Parameter, Template, TemplateElement,
+    BlockParam, DecoratorTemplate, HelperTemplate, Parameter, Template, TemplateElement,
     TemplateMapping,
 };
 
@@ -120,7 +120,7 @@ impl<'reg: 'rc, 'rc> RenderContext<'reg, 'rc> {
     }
 
     /// Set new context data into the render process.
-    /// This is typically called in directives where user can modify
+    /// This is typically called in decorators where user can modify
     /// the data they were rendering.
     pub fn set_context(&mut self, ctx: Context) {
         self.modified_context = Some(Rc::new(ctx))
@@ -129,7 +129,7 @@ impl<'reg: 'rc, 'rc> RenderContext<'reg, 'rc> {
     /// Evaluate a Json path in current scope.
     ///
     /// Typically you don't need to evaluate it by your self.
-    /// The Helper and Directive API will provide your evaluated value of
+    /// The Helper and Decorator API will provide your evaluated value of
     /// their parameters and hash data.
     pub fn evaluate(
         &self,
@@ -184,7 +184,7 @@ impl<'reg: 'rc, 'rc> RenderContext<'reg, 'rc> {
     }
 
     /// Register a helper in this render context.
-    /// This is a feature provided by Directive where you can create
+    /// This is a feature provided by Decorator where you can create
     /// temporary helpers.
     pub fn register_local_helper(
         &mut self,
@@ -393,22 +393,22 @@ impl<'reg: 'rc, 'rc> Helper<'reg, 'rc> {
     }
 }
 
-/// Render-time Directive data when using in a directive definition
+/// Render-time Decorator data when using in a decorator definition
 #[derive(Debug)]
-pub struct Directive<'reg: 'rc, 'rc> {
+pub struct Decorator<'reg: 'rc, 'rc> {
     name: String,
     params: Vec<PathAndJson<'reg, 'rc>>,
     hash: BTreeMap<&'reg str, PathAndJson<'reg, 'rc>>,
     template: Option<&'reg Template>,
 }
 
-impl<'reg: 'rc, 'rc> Directive<'reg, 'rc> {
+impl<'reg: 'rc, 'rc> Decorator<'reg, 'rc> {
     fn try_from_template(
-        dt: &'reg DirectiveTemplate,
+        dt: &'reg DecoratorTemplate,
         registry: &'reg Registry,
         context: &'rc Context,
         render_context: &mut RenderContext<'reg, 'rc>,
-    ) -> Result<Directive<'reg, 'rc>, RenderError> {
+    ) -> Result<Decorator<'reg, 'rc>, RenderError> {
         let name = dt.name.expand_as_name(registry, context, render_context)?;
 
         let mut pv = Vec::with_capacity(dt.params.len());
@@ -423,7 +423,7 @@ impl<'reg: 'rc, 'rc> Directive<'reg, 'rc> {
             hm.insert(k.as_ref(), r);
         }
 
-        Ok(Directive {
+        Ok(Decorator {
             name,
             params: pv,
             hash: hm,
@@ -486,7 +486,7 @@ pub trait Renderable {
     }
 }
 
-/// Evaluate directive or decorator
+/// Evaluate decorator or decorator
 pub trait Evaluable {
     fn eval<'reg: 'rc, 'rc>(
         &'reg self,
@@ -752,9 +752,9 @@ impl Renderable for TemplateElement {
                 Ok(())
             }
             HelperBlock(ref ht) => render_helper(ht, registry, ctx, rc, out),
-            DirectiveExpression(_) | DirectiveBlock(_) => self.eval(registry, ctx, rc),
+            DecoratorExpression(_) | DecoratorBlock(_) => self.eval(registry, ctx, rc),
             PartialExpression(ref dt) | PartialBlock(ref dt) => {
-                let di = Directive::try_from_template(dt, registry, ctx, rc)?;
+                let di = Decorator::try_from_template(dt, registry, ctx, rc)?;
 
                 partial::expand_partial(&di, registry, ctx, rc, out)
             }
@@ -771,12 +771,12 @@ impl Evaluable for TemplateElement {
         rc: &mut RenderContext<'reg, 'rc>,
     ) -> Result<(), RenderError> {
         match *self {
-            DirectiveExpression(ref dt) | DirectiveBlock(ref dt) => {
-                let di = Directive::try_from_template(dt, registry, ctx, rc)?;
+            DecoratorExpression(ref dt) | DecoratorBlock(ref dt) => {
+                let di = Decorator::try_from_template(dt, registry, ctx, rc)?;
                 match registry.get_decorator(di.name()) {
                     Some(d) => d.call(&di, registry, ctx, rc),
                     None => Err(RenderError::new(format!(
-                        "Directive not defined: {:?}",
+                        "Decorator not defined: {:?}",
                         dt.name
                     ))),
                 }
diff --git a/src/template.rs b/src/template.rs
index ae327ec..653f9e7 100644
--- a/src/template.rs
+++ b/src/template.rs
@@ -141,7 +141,7 @@ impl HelperTemplate {
 }
 
 #[derive(PartialEq, Clone, Debug)]
-pub struct DirectiveTemplate {
+pub struct DecoratorTemplate {
     pub name: Parameter,
     pub params: Vec<Parameter>,
     pub hash: HashMap<String, Parameter>,
@@ -437,7 +437,7 @@ impl Template {
     pub fn compile2<S: AsRef<str>>(source: S, mapping: bool) -> Result<Template, TemplateError> {
         let source = source.as_ref();
         let mut helper_stack: VecDeque<HelperTemplate> = VecDeque::new();
-        let mut directive_stack: VecDeque<DirectiveTemplate> = VecDeque::new();
+        let mut decorator_stack: VecDeque<DecoratorTemplate> = VecDeque::new();
         let mut template_stack: VecDeque<Template> = VecDeque::new();
 
         let mut omit_pro_ws = false;
@@ -517,7 +517,7 @@ impl Template {
                     }
                     Rule::helper_block_start
                     | Rule::raw_block_start
-                    | Rule::directive_block_start
+                    | Rule::decorator_block_start
                     | Rule::partial_block_start => {
                         let exp = Template::parse_expression(source, it.by_ref(), span.end())?;
 
@@ -534,14 +534,14 @@ impl Template {
                                 };
                                 helper_stack.push_front(helper_template);
                             }
-                            Rule::directive_block_start | Rule::partial_block_start => {
-                                let directive = DirectiveTemplate {
+                            Rule::decorator_block_start | Rule::partial_block_start => {
+                                let decorator = DecoratorTemplate {
                                     name: exp.name,
                                     params: exp.params,
                                     hash: exp.hash,
                                     template: None,
                                 };
-                                directive_stack.push_front(directive);
+                                decorator_stack.push_front(decorator);
                             }
                             _ => unreachable!(),
                         }
@@ -581,11 +581,11 @@ impl Template {
                     }
                     Rule::expression
                     | Rule::html_expression
-                    | Rule::directive_expression
+                    | Rule::decorator_expression
                     | Rule::partial_expression
                     | Rule::helper_block_end
                     | Rule::raw_block_end
-                    | Rule::directive_block_end
+                    | Rule::decorator_block_end
                     | Rule::partial_block_end => {
                         let exp = Template::parse_expression(source, it.by_ref(), span.end())?;
                         if exp.omit_pre_ws {
@@ -614,17 +614,17 @@ impl Template {
                                 let t = template_stack.front_mut().unwrap();
                                 t.push_element(el, line_no, col_no);
                             }
-                            Rule::directive_expression | Rule::partial_expression => {
-                                let directive = DirectiveTemplate {
+                            Rule::decorator_expression | Rule::partial_expression => {
+                                let decorator = DecoratorTemplate {
                                     name: exp.name,
                                     params: exp.params,
                                     hash: exp.hash,
                                     template: None,
                                 };
-                                let el = if rule == Rule::directive_expression {
-                                    DirectiveExpression(Box::new(directive))
+                                let el = if rule == Rule::decorator_expression {
+                                    DecoratorExpression(Box::new(decorator))
                                 } else {
-                                    PartialExpression(Box::new(directive))
+                                    PartialExpression(Box::new(decorator))
                                 };
                                 let t = template_stack.front_mut().unwrap();
                                 t.push_element(el, line_no, col_no);
@@ -651,21 +651,21 @@ impl Template {
                                     .at(source, line_no, col_no));
                                 }
                             }
-                            Rule::directive_block_end | Rule::partial_block_end => {
-                                let mut d = directive_stack.pop_front().unwrap();
+                            Rule::decorator_block_end | Rule::partial_block_end => {
+                                let mut d = decorator_stack.pop_front().unwrap();
                                 let close_tag_name = exp.name.as_name();
                                 if d.name.as_name() == close_tag_name {
                                     let prev_t = template_stack.pop_front().unwrap();
                                     d.template = Some(prev_t);
                                     let t = template_stack.front_mut().unwrap();
-                                    if rule == Rule::directive_block_end {
-                                        t.elements.push(DirectiveBlock(Box::new(d)));
+                                    if rule == Rule::decorator_block_end {
+                                        t.elements.push(DecoratorBlock(Box::new(d)));
                                     } else {
                                         t.elements.push(PartialBlock(Box::new(d)));
                                     }
                                 } else {
                                     return Err(TemplateError::of(
-                                        TemplateErrorReason::MismatchingClosedDirective(
+                                        TemplateErrorReason::MismatchingClosedDecorator(
                                             d.name.as_name().unwrap().into(),
                                             close_tag_name.unwrap().into(),
                                         ),
@@ -733,10 +733,10 @@ pub enum TemplateElement {
     HTMLExpression(Parameter),
     Expression(Box<HelperTemplate>),
     HelperBlock(Box<HelperTemplate>),
-    DirectiveExpression(Box<DirectiveTemplate>),
-    DirectiveBlock(Box<DirectiveTemplate>),
-    PartialExpression(Box<DirectiveTemplate>),
-    PartialBlock(Box<DirectiveTemplate>),
+    DecoratorExpression(Box<DecoratorTemplate>),
+    DecoratorBlock(Box<DecoratorTemplate>),
+    PartialExpression(Box<DecoratorTemplate>),
+    PartialBlock(Box<DecoratorTemplate>),
     Comment(String),
 }
 
@@ -1080,11 +1080,11 @@ fn test_block_param() {
 }
 
 #[test]
-fn test_directive() {
+fn test_decorator() {
     match Template::compile("hello {{* ssh}} world") {
         Err(e) => panic!("{}", e),
         Ok(t) => {
-            if let DirectiveExpression(ref de) = t.elements[1] {
+            if let DecoratorExpression(ref de) = t.elements[1] {
                 assert_eq!(de.name.as_name(), Some("ssh"));
                 assert_eq!(de.template, None);
             }
@@ -1104,7 +1104,7 @@ fn test_directive() {
     match Template::compile("{{#*inline \"hello\"}}expand to hello{{/inline}}{{> hello}}") {
         Err(e) => panic!("{}", e),
         Ok(t) => {
-            if let DirectiveBlock(ref db) = t.elements[0] {
+            if let DecoratorBlock(ref db) = t.elements[0] {
                 assert_eq!(db.name, Parameter::Name("inline".to_owned()));
                 assert_eq!(
                     db.params[0],


Test patch:
diff --git a/tests/block_context.rs b/tests/block_context.rs
index bbaa89a..7d42db9 100644
--- a/tests/block_context.rs
+++ b/tests/block_context.rs
@@ -74,33 +74,3 @@ fn test_nested_each() {
     let template = "{{#each classes as |class|}}{{#each class.methods as |method|}}{{method.id}};{{/each}}{{/each}}";
     assert_eq!(hbs.render_template(template, &data).unwrap(), "1;2;3;4;");
 }
-
-#[test]
-fn test_referencing_block_param_from_upper_scope() {
-    let hbs = Handlebars::new();
-
-    let data = json!({
-        "classes": [
-            {
-                "methods": [
-                    {"id": 1},
-                    {"id": 2}
-                ],
-                "private": false
-            },
-            {
-                "methods": [
-                    {"id": 3},
-                    {"id": 4}
-                ],
-                "private": true
-            },
-        ],
-    });
-
-    let template = "{{#each classes as |class|}}{{#each class.methods as |method|}}{{class.private}}|{{method.id}};{{/each}}{{/each}}";
-    assert_eq!(
-        hbs.render_template(template, &data).unwrap(),
-        "false|1;false|2;true|3;true|4;"
-    );
-}