Пример #1
0
 public function testFind()
 {
     $context = new Mustache_Context();
     $dummy = new Mustache_Test_TestDummy();
     $obj = new StdClass();
     $obj->name = 'obj';
     $arr = array('a' => array('b' => array('c' => 'see')), 'b' => 'bee');
     $string = 'some arbitrary string';
     $context->push($dummy);
     $this->assertEquals('dummy', $context->find('name'));
     $context->push($obj);
     $this->assertEquals('obj', $context->find('name'));
     $context->pop();
     $this->assertEquals('dummy', $context->find('name'));
     $dummy->name = 'dummyer';
     $this->assertEquals('dummyer', $context->find('name'));
     $context->push($arr);
     $this->assertEquals('bee', $context->find('b'));
     $this->assertEquals('see', $context->findDot('a.b.c'));
     $dummy->name = 'dummy';
     $context->push($string);
     $this->assertSame($string, $context->last());
     $this->assertEquals('dummy', $context->find('name'));
     $this->assertEquals('see', $context->findDot('a.b.c'));
     $this->assertEquals('<foo>', $context->find('foo'));
     $this->assertEquals('<bar>', $context->findDot('bar'));
 }
 public function testArrayAccessFind()
 {
     $access = new Mustache_Test_TestArrayAccess(array('a' => array('b' => array('c' => 'see')), 'b' => 'bee'));
     $context = new Mustache_Context($access);
     $this->assertEquals('bee', $context->find('b'));
     $this->assertEquals('see', $context->findDot('a.b.c'));
     $this->assertEquals(null, $context->findDot('a.b.c.d'));
 }
    public function renderInternal(Mustache_Context $context, $indent = '')
    {
        $this->lambdaHelper = new Mustache_LambdaHelper($this->mustache, $context);
        $buffer = '';
        $newContext = array();

        // 'id_commande' section
        $value = $context->find('id_commande');
        $filter = $context->findDot('session.peutModifierCommande');
        if (!(!is_string($filter) && is_callable($filter))) {
            throw new Mustache_Exception_UnknownFilterException('session.peutModifierCommande');
        }
        $value = call_user_func($filter, $value);
        $buffer .= $this->section3fc8f3fb3e9f21dac97a46559e49f5e8($context, $indent, $value);
        // 'id_commande' inverted section
        $value = $context->find('id_commande');
        $filter = $context->findDot('session.peutModifierCommande');
        if (!(!is_string($filter) && is_callable($filter))) {
            throw new Mustache_Exception_UnknownFilterException('session.peutModifierCommande');
        }
        $value = call_user_func($filter, $value);
        if (empty($value)) {
            
            if ($partial = $this->mustache->loadPartial('ElementCommande-quantite_commande')) {
                $buffer .= $partial->renderInternal($context);
            }
        }
        $buffer .= $indent . '
';
        return $buffer;
    }
    public function renderInternal(Mustache_Context $context, $indent = '')
    {
        $this->lambdaHelper = new Mustache_LambdaHelper($this->mustache, $context);
        $buffer = '';
        $newContext = array();

        // 'session.estAuthentifier' section
        $value = $context->findDot('session.estAuthentifier');
        $buffer .= $this->sectionFda7f2a12d9d2b8a1268e4a87f64f019($context, $indent, $value);
        $buffer .= $indent . '
';
        // 'session.estAdministrateur' section
        $value = $context->findDot('session.estAdministrateur');
        $buffer .= $this->sectionB3594982365cb47b6d4ca4e91cb1004e($context, $indent, $value);
        return $buffer;
    }
    public function renderInternal(Mustache_Context $context, $indent = '')
    {
        $this->lambdaHelper = new Mustache_LambdaHelper($this->mustache, $context);
        $buffer = '';
        $newContext = array();

        // 'session.estAuthentifier' section
        $value = $context->findDot('session.estAuthentifier');
        $buffer .= $this->sectionFda7f2a12d9d2b8a1268e4a87f64f019($context, $indent, $value);
        $buffer .= $indent . '
';
        // 'session.estAdministrateur' section
        $value = $context->findDot('session.estAdministrateur');
        $buffer .= $this->section3205c7f64d4a1dfffbce5fcb2809a8cc($context, $indent, $value);
        return $buffer;
    }
    public function renderInternal(Mustache_Context $context, $indent = '')
    {
        $this->lambdaHelper = new Mustache_LambdaHelper($this->mustache, $context);
        $buffer = '';
        $newContext = array();

        // 'session.estAuthentifier' section
        $value = $context->findDot('session.estAuthentifier');
        $buffer .= $this->sectionFda7f2a12d9d2b8a1268e4a87f64f019($context, $indent, $value);
        $buffer .= $indent . '
';
        // 'session.estAdministrateur' section
        $value = $context->findDot('session.estAdministrateur');
        $buffer .= $this->section6c04fe64d8b3a4db5e89f6ed3baca754($context, $indent, $value);
        return $buffer;
    }
    public function renderInternal(Mustache_Context $context, $indent = '')
    {
        $this->lambdaHelper = new Mustache_LambdaHelper($this->mustache, $context);
        $buffer = '';
        $newContext = array();

        // 'session.estAdministrateur' section
        $value = $context->findDot('session.estAdministrateur');
        $buffer .= $this->section5278dbf1bb4c35cba452ade388cfc791($context, $indent, $value);
        // 'session.estAdministrateur' inverted section
        $value = $context->findDot('session.estAdministrateur');
        if (empty($value)) {
            
            if ($partial = $this->mustache->loadPartial('Produit-prix_unitaire_ttc')) {
                $buffer .= $partial->renderInternal($context, $indent . '    ');
            }
        }
        return $buffer;
    }
    public function renderInternal(Mustache_Context $context, $indent = '')
    {
        $this->lambdaHelper = new Mustache_LambdaHelper($this->mustache, $context);
        $buffer = '';
        $newContext = array();

        // 'session.estAdministrateur' section
        $value = $context->findDot('session.estAdministrateur');
        $buffer .= $this->section83cfc81452a68251145db0dd059adb79($context, $indent, $value);
        // 'session.estAdministrateur' inverted section
        $value = $context->findDot('session.estAdministrateur');
        if (empty($value)) {
            
            if ($partial = $this->mustache->loadPartial('Produit-description')) {
                $buffer .= $partial->renderInternal($context, $indent . '    ');
            }
        }
        return $buffer;
    }
    public function renderInternal(Mustache_Context $context, $indent = '')
    {
        $this->lambdaHelper = new Mustache_LambdaHelper($this->mustache, $context);
        $buffer = '';
        $newContext = array();

        // 'session.estAdministrateur' section
        $value = $context->findDot('session.estAdministrateur');
        $buffer .= $this->sectionCdcdeee3abca972c41eaef086b3140d7($context, $indent, $value);
        // 'session.estAdministrateur' inverted section
        $value = $context->findDot('session.estAdministrateur');
        if (empty($value)) {
            
            if ($partial = $this->mustache->loadPartial('Produit-unite')) {
                $buffer .= $partial->renderInternal($context, $indent . '    ');
            }
        }
        return $buffer;
    }
    public function renderInternal(Mustache_Context $context, $indent = '')
    {
        $this->lambdaHelper = new Mustache_LambdaHelper($this->mustache, $context);
        $buffer = '';
        $newContext = array();

        // 'session.estAdministrateur' section
        $value = $context->findDot('session.estAdministrateur');
        $buffer .= $this->section37a58b1dcb96e8253319508e4bcc02c5($context, $indent, $value);
        // 'session.estAdministrateur' inverted section
        $value = $context->findDot('session.estAdministrateur');
        if (empty($value)) {
            
            if ($partial = $this->mustache->loadPartial('Produit-unite')) {
                $buffer .= $partial->renderInternal($context, $indent . '    ');
            }
        }
        return $buffer;
    }
    public function renderInternal(Mustache_Context $context, $indent = '')
    {
        $this->lambdaHelper = new Mustache_LambdaHelper($this->mustache, $context);
        $buffer = '';
        $newContext = array();

        // 'session.estAdministrateur' section
        $value = $context->findDot('session.estAdministrateur');
        $buffer .= $this->sectionF067d5a41d1a60f8c73ac95b396b6ba3($context, $indent, $value);
        // 'session.estAdministrateur' inverted section
        $value = $context->findDot('session.estAdministrateur');
        if (empty($value)) {
            
            if ($partial = $this->mustache->loadPartial('Produit-nom')) {
                $buffer .= $partial->renderInternal($context);
            }
        }
        $buffer .= $indent . '
';
        return $buffer;
    }
    public function renderInternal(Mustache_Context $context, $indent = '')
    {
        $this->lambdaHelper = new Mustache_LambdaHelper($this->mustache, $context);
        $buffer = '';
        $newContext = array();

        // 'session.estAdministrateur' section
        $value = $context->findDot('session.estAdministrateur');
        $buffer .= $this->section8383f823e45c9eb13bdb11c5c71db565($context, $indent, $value);
        // 'session.estAdministrateur' inverted section
        $value = $context->findDot('session.estAdministrateur');
        if (empty($value)) {
            
            if ($partial = $this->mustache->loadPartial('Produit-nom')) {
                $buffer .= $partial->renderInternal($context);
            }
        }
        $buffer .= $indent . '
';
        return $buffer;
    }
Пример #13
0
 public function testAnchoredDotNotation()
 {
     $context = new Mustache_Context();
     $a = array('name' => 'a', 'number' => 1);
     $b = array('number' => 2, 'child' => array('name' => 'baby bee'));
     $c = array('name' => 'cee');
     $context->push($a);
     $this->assertEquals('a', $context->find('name'));
     $this->assertEquals('', $context->findDot('.name'));
     $this->assertEquals('a', $context->findAnchoredDot('.name'));
     $this->assertEquals(1, $context->find('number'));
     $this->assertEquals('', $context->findDot('.number'));
     $this->assertEquals(1, $context->findAnchoredDot('.number'));
     $context->push($b);
     $this->assertEquals('a', $context->find('name'));
     $this->assertEquals(2, $context->find('number'));
     $this->assertEquals('', $context->findDot('.name'));
     $this->assertEquals('', $context->findDot('.number'));
     $this->assertEquals('', $context->findAnchoredDot('.name'));
     $this->assertEquals(2, $context->findAnchoredDot('.number'));
     $this->assertEquals('baby bee', $context->findDot('child.name'));
     $this->assertEquals('', $context->findDot('.child.name'));
     $this->assertEquals('baby bee', $context->findAnchoredDot('.child.name'));
     $context->push($c);
     $this->assertEquals('cee', $context->find('name'));
     $this->assertEquals('', $context->findDot('.name'));
     $this->assertEquals('cee', $context->findAnchoredDot('.name'));
     $this->assertEquals(2, $context->find('number'));
     $this->assertEquals('', $context->findDot('.number'));
     $this->assertEquals('', $context->findAnchoredDot('.number'));
     $this->assertEquals('baby bee', $context->findDot('child.name'));
     $this->assertEquals('', $context->findDot('.child.name'));
     $this->assertEquals('', $context->findAnchoredDot('.child.name'));
 }