2014-06-27 22 views
0

後symfony的更新後,呈現標籤簽名已經改變(https://github.com/symfony/symfony/blob/master/UPGRADE-2.2.md):正則表達式來更新symfony的渲染標籤簽名更新

前:

{% render 'BlogBundle:Post:list' with { 'limit': 2 }, { 'alt': 'BlogBundle:Post:error' } %} 

後:

{% render controller('BlogBundle:Post:list', { 'limit': 2 }), { 'alt': 'BlogBundle:Post:error' } %} 
{# Or: #} 
{{ render(controller('BlogBundle:Post:list', { 'limit': 2 }), { 'alt': 'BlogBundle:Post:error'}) }} 

我尋找一種方法來使用一些正則表達式自動修改我的通話。 任何人都可以幫忙嗎?

+0

什麼是輸入,什麼是所需的輸出?對不起,但你不清楚你的問題。 :) – zx81

+0

真的值得嗎?必須修復代碼中的多少位置? –

+0

'BlogBu​​ndle:Post:list','limit':2,'alt':'BlogBu​​ndle:Post:error'是可選的輸入。我有大約50個需要修復的條目。另外,在切換到新版本時,我希望儘可能減少停機時間。 –

回答

0

取代:

\{% render ([^,%]*?), ([^%]*?)%\} 

有:

{% render controller(\1), \2%} 
+0

這假設總是有一個逗號和(確切)兩個部分需要替換。它適用於您的示例,但您應該檢查是否有其他形式的輸入。 –

+0

很好,thanx。我會試試看 –