Thanks. But how about auth controller? When i open auth page with T in layout.html it falls with error, that T is undefined.
пятница, 11 октября 2019 г., 11:19:17 UTC+5 пользователь Massimo Di Pierro написал: > > No. You should not define T in your view and your should not define T in > your actions. > > T should be defined outside actions (for example it is defined in > common.py in _scaffold). > > Your actions should declare that they need it and pass it to the view: > > @action('index') > @action.uses(index.html) > @action.uses(T) > def index(): > return dict(T=T) > > now index.html can see and use T > > > > > > > > On Monday, 7 October 2019 06:06:40 UTC-7, Ruslan Gareev wrote: >> >> Using T in Layout.html is make me to copy-paste code from common.py to >> layout.html >> [[from py4web import Translator]] >> [[from ..settings import T_FOLDER]] >> [[T = Translator(T_FOLDER)]] >> >> <html> >> some code >> ... >> <a href="[[=URL('auth/register')]]">[[=T('Sign in')]] >> ... >> </html> >> How to make that no repeat code? >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/38de7b27-6e14-4f50-b40f-22bc759be80f%40googlegroups.com.