inline void print( std::ostream& out
                  , frontend::stache::ast::root const & root
                  , stache_model const & model)
 {
    detail::stache_model_printer p(out, model);
    apply_visitor_to_root(p, root);
 }
예제 #2
0
         void operator()(section const & v) const
         {
				const stache_variant* location = lookup(v.name);
				bool positive = have_value(location);
				if( positive && !v.is_inverted )
				{
					if (auto vec = get<stache_model_vector>(location))
					{
						for( const auto& entry : *vec )
						{
							const stache_model* m = boost::get<stache_model>(&entry);
							if( m )
							{
								stache_model_printer section_printer(out, *m, this);
								apply_visitor_to_root(section_printer, v.nodes);
							}
							else
							{
								apply_visitor_to_root(*this, v.nodes);
							}
						}
					}
					else if (auto model = get<stache_model>(location))
					{
						stache_model_printer section_printer(out, *model, this);
						apply_visitor_to_root(section_printer, v.nodes);
					}
					else
					{
						// This is the odd case that they requested a section, but it was
						// some non-mapped type.  We can handle this by recursively calling
						// the printer with the nodes of the section.  Dynamic lookup can
						// still find the section tag for proper display within the
						// section.
						apply_visitor_to_root(*this, v.nodes);
					}
				}
				else if( !positive && v.is_inverted )
				{
					apply_visitor_to_root(stache_model_printer(out, stache_model(), this), v.nodes);
				}
         }
예제 #3
0
   inline void print(std::ostream& out, stache_root const& root, const stache_model& model)
   {
      detail::stache_model_printer p(out, model);
		apply_visitor_to_root(p, root.nodes);
   }