Everyone knows that Magento supports comparison in email templates, but if you need to use an equal comparison to check if some variable f.e. (in order template) “shipping method” is equal to “some_cool_shipping_method” then Magento doesn’t support this construction. And what we can do we this?

How it's could be configured in Magento by-default:

{{if var order.getShippingMethod()}}
Shipping method is {{var order.getShippingMethod()}}
{{else}}
Shipping method isn't listed.
{{/if}} 

How it's should be configured in Magento according our requirements:

{{if var order.getShippingMethod() = some_cool_shipping_method}}
Shipping method is {{var order.getShippingMethod()}}
{{else}}
Shipping method isn't listed.
{{/if}}

The point is that the second case isn't supported in Magento by-defult, so here we can consider class Varien_Filter_Template that is responsible for "if" condition statements, exactly in method "ifDirective". Here it's:

public function ifDirective($construction)
{
    if (count($this->_templateVars) == 0) {
        return $construction[0];
    }

    if($this->_getVariable($construction[1], '') == '') {
        if (isset($construction[3]) && isset($construction[4])) {
            return $construction[4];
        }
        return '';
    } else {
        return $construction[2];
    }
}

The structure of the $construction array is following:

Array
(
    [0] => {{if var order.getShippingMethod()}}
Shipping method is {{var order.getShippingMethod()}}
{{else}}
Shipping method isn't listed.
{{/if}}
    [1] => var order.getShippingMethod()
    [2] => Shipping method is {{var order.getShippingMethod()}}
    [3] => {{else}}Shipping method isn't listed.
    [4] => Shipping method isn't listed.
)

So, according to the algorithm we can say that if variable in $construction[1] not empty then we return $construction[2]. If variable in $construction[1] is empty then check if "else" condition and "else" value are persist then return $construction[4]. Just remind our task is to add condition to compare some value exactly what we need in $construction[0] is {{if var order.getShippingMethod() = some_cool_shipping_method}}. Here the rewrite comes:

    public function ifDirective($construction)
    {
        if (count($this->_templateVars) == 0) {
            return $construction[0];
        }

        //Custom code starts. Support equal condition {{if var somevar = some param}}  -->
        $array = explode('=', $construction[1]);
        if (count($array) >= 2) {
            $variable = trim($array[0]);
            $value = trim($array[1]);

            if($this->_getVariable($variable, '') == $value) {
                return $construction[2];
            } else {
                if (isset($construction[3]) && isset($construction[4])) {
                    return $construction[4];
                }
                return '';
            }
        }
        //_getVariable($construction[1], '') == '') {
            if (isset($construction[3]) && isset($construction[4])) {
                return $construction[4];
            }
            return '';
        } else {
            return $construction[2];
        }
    }

And that it, use this code in order to compare some value in any email templates. You can download separated extension from github here.