private function prepareAttributeConditional(PHPTAL_Php_CodeWriter $codewriter, $qname, $code)
    {
        // regular attribute which value is the evaluation of $code
        $attkey = $this->getVarName($qname, $codewriter);

        $codewriter->doIf("null !== ($attkey = ($code))");

        if ($this->_echoType !== PHPTAL_Php_Attribute::ECHO_STRUCTURE)
            $codewriter->doSetVar($attkey, $codewriter->str(" $qname=\"").".".$codewriter->escapeCode($attkey).".'\"'");
        else
            $codewriter->doSetVar($attkey, $codewriter->str(" $qname=\"").".".$codewriter->stringifyCode($attkey).".'\"'");

        $codewriter->doElse();
        $codewriter->doSetVar($attkey, "''");
        $codewriter->doEnd('if');

        $this->phpelement->getOrCreateAttributeNode($qname)->overwriteFullWithVariable($attkey);
    }