text: <!DOCTYPE html>
  
  <html>
  <head>
  <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  
  <title>class Liquid::Unless - liquid-3.0.6 Documentation</title>
  
  <link type="text/css" media="screen" href="../rdoc.css" rel="stylesheet">
  
  <script type="text/javascript">
    var rdoc_rel_prefix = "../";
  </script>
  
  <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
  <script type="text/javascript" charset="utf-8" src="../js/navigation.js"></script>
  <script type="text/javascript" charset="utf-8" src="../js/search_index.js"></script>
  <script type="text/javascript" charset="utf-8" src="../js/search.js"></script>
  <script type="text/javascript" charset="utf-8" src="../js/searcher.js"></script>
  <script type="text/javascript" charset="utf-8" src="../js/darkfish.js"></script>
  
  
  <body id="top" class="class">
  <nav id="metadata">
    <nav id="home-section" class="section">
    <h3 class="section-header">
      <a href="../index.html">Home</a>
      <a href="../table_of_contents.html#classes">Classes</a>
      <a href="../table_of_contents.html#methods">Methods</a>
    </h3>
  </nav>
  
  
    <nav id="search-section" class="section project-section" class="initially-hidden">
    <form action="#" method="get" accept-charset="utf-8">
      <h3 class="section-header">
        <input type="text" name="search" placeholder="Search" id="search-field"
               title="Type to search, Up and Down to navigate, Enter to load">
      </h3>
    </form>
  
    <ul id="search-results" class="initially-hidden"></ul>
  </nav>
  
  
    
  
    <div id="file-metadata">
      <nav id="file-list-section" class="section">
    <h3 class="section-header">Defined In</h3>
    <ul>
      <li>lib/liquid/tags/unless.rb
    </ul>
  </nav>
  
      
    </div>
  
    <div id="class-metadata">
      
      <nav id="parent-class-section" class="section">
    <h3 class="section-header">Parent</h3>
    
    <p class="link"><a href="If.html">Liquid::If</a>
    
  </nav>
  
      
      
      <!-- Method Quickref -->
  <nav id="method-list-section" class="section">
    <h3 class="section-header">Methods</h3>
  
    <ul class="link-list">
      
      <li ><a href="#method-i-render">#render</a>
      
    </ul>
  </nav>
  
    </div>
  
    <div id="project-metadata">
      <nav id="fileindex-section" class="section project-section">
    <h3 class="section-header">Pages</h3>
  
    <ul>
    
      <li class="file"><a href="../History_md.html">History</a>
    
      <li class="file"><a href="../README_md.html">README</a>
    
    </ul>
  </nav>
  
      <nav id="classindex-section" class="section project-section">
    <h3 class="section-header">Class and Module Index</h3>
  
    <ul class="link-list">
    
      <li><a href="../Array.html">Array</a>
    
      <li><a href="../Date.html">Date</a>
    
      <li><a href="../DateTime.html">DateTime</a>
    
      <li><a href="../FalseClass.html">FalseClass</a>
    
      <li><a href="../Hash.html">Hash</a>
    
      <li><a href="../Liquid.html">Liquid</a>
    
      <li><a href="../Liquid/ArgumentError.html">Liquid::ArgumentError</a>
    
      <li><a href="../Liquid/Assign.html">Liquid::Assign</a>
    
      <li><a href="../Liquid/BlankFileSystem.html">Liquid::BlankFileSystem</a>
    
      <li><a href="../Liquid/Block.html">Liquid::Block</a>
    
      <li><a href="../Liquid/BlockBody.html">Liquid::BlockBody</a>
    
      <li><a href="../Liquid/Break.html">Liquid::Break</a>
    
      <li><a href="../Liquid/BreakInterrupt.html">Liquid::BreakInterrupt</a>
    
      <li><a href="../Liquid/Capture.html">Liquid::Capture</a>
    
      <li><a href="../Liquid/Case.html">Liquid::Case</a>
    
      <li><a href="../Liquid/Comment.html">Liquid::Comment</a>
    
      <li><a href="../Liquid/Condition.html">Liquid::Condition</a>
    
      <li><a href="../Liquid/Context.html">Liquid::Context</a>
    
      <li><a href="../Liquid/ContextError.html">Liquid::ContextError</a>
    
      <li><a href="../Liquid/Continue.html">Liquid::Continue</a>
    
      <li><a href="../Liquid/ContinueInterrupt.html">Liquid::ContinueInterrupt</a>
    
      <li><a href="../Liquid/Cycle.html">Liquid::Cycle</a>
    
      <li><a href="../Liquid/Decrement.html">Liquid::Decrement</a>
    
      <li><a href="../Liquid/Document.html">Liquid::Document</a>
    
      <li><a href="../Liquid/Drop.html">Liquid::Drop</a>
    
      <li><a href="../Liquid/ElseCondition.html">Liquid::ElseCondition</a>
    
      <li><a href="../Liquid/Error.html">Liquid::Error</a>
    
      <li><a href="../Liquid/Expression.html">Liquid::Expression</a>
    
      <li><a href="../Liquid/FileSystemError.html">Liquid::FileSystemError</a>
    
      <li><a href="../Liquid/For.html">Liquid::For</a>
    
      <li><a href="../Liquid/I18n.html">Liquid::I18n</a>
    
      <li><a href="../Liquid/I18n/TranslationError.html">Liquid::I18n::TranslationError</a>
    
      <li><a href="../Liquid/If.html">Liquid::If</a>
    
      <li><a href="../Liquid/Ifchanged.html">Liquid::Ifchanged</a>
    
      <li><a href="../Liquid/Include.html">Liquid::Include</a>
    
      <li><a href="../Liquid/Increment.html">Liquid::Increment</a>
    
      <li><a href="../Liquid/Interrupt.html">Liquid::Interrupt</a>
    
      <li><a href="../Liquid/Lexer.html">Liquid::Lexer</a>
    
      <li><a href="../Liquid/LocalFileSystem.html">Liquid::LocalFileSystem</a>
    
      <li><a href="../Liquid/MemoryError.html">Liquid::MemoryError</a>
    
      <li><a href="../Liquid/Parser.html">Liquid::Parser</a>
    
      <li><a href="../Liquid/ParserSwitching.html">Liquid::ParserSwitching</a>
    
      <li><a href="../Liquid/Profiler.html">Liquid::Profiler</a>
    
      <li><a href="../Liquid/Profiler/Timing.html">Liquid::Profiler::Timing</a>
    
      <li><a href="../Liquid/RangeLookup.html">Liquid::RangeLookup</a>
    
      <li><a href="../Liquid/Raw.html">Liquid::Raw</a>
    
      <li><a href="../Liquid/StackLevelError.html">Liquid::StackLevelError</a>
    
      <li><a href="../Liquid/StandardError.html">Liquid::StandardError</a>
    
      <li><a href="../Liquid/StandardFilters.html">Liquid::StandardFilters</a>
    
      <li><a href="../Liquid/StandardFilters/InputIterator.html">Liquid::StandardFilters::InputIterator</a>
    
      <li><a href="../Liquid/Strainer.html">Liquid::Strainer</a>
    
      <li><a href="../Liquid/SyntaxError.html">Liquid::SyntaxError</a>
    
      <li><a href="../Liquid/TableRow.html">Liquid::TableRow</a>
    
      <li><a href="../Liquid/Tag.html">Liquid::Tag</a>
    
      <li><a href="../Liquid/TaintedError.html">Liquid::TaintedError</a>
    
      <li><a href="../Liquid/Template.html">Liquid::Template</a>
    
      <li><a href="../Liquid/Template/TagRegistry.html">Liquid::Template::TagRegistry</a>
    
      <li><a href="../Liquid/Token.html">Liquid::Token</a>
    
      <li><a href="../Liquid/Unless.html">Liquid::Unless</a>
    
      <li><a href="../Liquid/Utils.html">Liquid::Utils</a>
    
      <li><a href="../Liquid/Variable.html">Liquid::Variable</a>
    
      <li><a href="../Liquid/VariableLookup.html">Liquid::VariableLookup</a>
    
      <li><a href="../Module.html">Module</a>
    
      <li><a href="../NilClass.html">NilClass</a>
    
      <li><a href="../Numeric.html">Numeric</a>
    
      <li><a href="../String.html">String</a>
    
      <li><a href="../Time.html">Time</a>
    
      <li><a href="../TrueClass.html">TrueClass</a>
    
    </ul>
  </nav>
  
    </div>
  </nav>
  
  <div id="documentation">
    <h1 class="class">class Liquid::Unless</h1>
  
    <div id="description" class="description">
      
  <p><a href="Unless.html">Unless</a> is a conditional just like &#39;if&#39;
  but works on the inverse logic.</p>
  
  <pre>{% unless x &lt; 0 %} x is greater than zero {% endunless %}</pre>
  
    </div><!-- description -->
  
    
    
    
    <section id="5Buntitled-5D" class="documentation-section">
      
  
      
  
      
  
      
  
      <!-- Methods -->
      
       <section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
        <h3 class="section-header">Public Instance Methods</h3>
  
      
        <div id="method-i-render" class="method-detail ">
          
          <div class="method-heading">
            <span class="method-name">render</span><span
              class="method-args">(context)</span>
            
            <span class="method-click-advice">click to toggle source</span>
            
          </div>
          
  
          <div class="method-description">
            
            
            
            
  
            
            <div class="method-source-code" id="render-source">
              <pre><span class="ruby-comment"># File lib/liquid/tags/unless.rb, line 9</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">render</span>(<span class="ruby-identifier">context</span>)
    <span class="ruby-identifier">context</span>.<span class="ruby-identifier">stack</span> <span class="ruby-keyword">do</span>
  
      <span class="ruby-comment"># First condition is interpreted backwards ( if not )</span>
      <span class="ruby-identifier">first_block</span> = <span class="ruby-ivar">@blocks</span>.<span class="ruby-identifier">first</span>
      <span class="ruby-keyword">unless</span> <span class="ruby-identifier">first_block</span>.<span class="ruby-identifier">evaluate</span>(<span class="ruby-identifier">context</span>)
        <span class="ruby-keyword">return</span> <span class="ruby-identifier">render_all</span>(<span class="ruby-identifier">first_block</span>.<span class="ruby-identifier">attachment</span>, <span class="ruby-identifier">context</span>)
      <span class="ruby-keyword">end</span>
  
      <span class="ruby-comment"># After the first condition unless works just like if</span>
      <span class="ruby-ivar">@blocks</span>[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">block</span><span class="ruby-operator">|</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">block</span>.<span class="ruby-identifier">evaluate</span>(<span class="ruby-identifier">context</span>)
          <span class="ruby-keyword">return</span> <span class="ruby-identifier">render_all</span>(<span class="ruby-identifier">block</span>.<span class="ruby-identifier">attachment</span>, <span class="ruby-identifier">context</span>)
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
  
      <span class="ruby-string">&#39;&#39;</span>.<span class="ruby-identifier">freeze</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span></pre>
            </div><!-- render-source -->
            
          </div>
  
          
  
          
        </div><!-- render-method -->
  
      
      </section><!-- public-instance-method-details -->
    
    </section><!-- 5Buntitled-5D -->
  
  </div><!-- documentation -->
  
  
  <footer id="validator-badges">
    <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
    <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 4.0.0.
    <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
  </footer>
  
  