Template-Toolkit似乎總想將undef插入到空字符串中。所以這樣的一個模板:如何將undef作爲參數傳遞給TT模板中的對象方法?
Result is [% some_object.some_method (1, undef, 2) %]
或本:
Result is [% ttvar %]
[% some_object.some_method (1, ttvar, 2) %]
產生調用類似Perl:
some_object->some_method (1, '', 2)
當我要的是:
some_object->some_method (1, undef, 2)
有沒有辦法傳遞undef而不是空字符串?
你需要空字符串和民主基金的情況加以區分,或者是確定只是轉換空字符串爲'undef'? – 2009-11-03 14:26:03
是的,這就是整個觀點 - 我需要保持undef undef,而不是TT將它改爲空字符串。即perl方法需要能夠檢查參數是否被定義。 – 2009-11-03 14:33:10