Closed miguelavaqrod closed 5 years ago
It's not good idea because view can be compiled in VIEW()
method (outside of controller), etc.. I don't see any sense for it. Why do you need it?
Let me indicate an example:
Imagine you want to alter default layout.html file without touching it and, maybe... you need different code based on language.
You create, for example, a module with this code:
/ QUICK AND DIRTY / F.modify(function(type, filename, body, controller){ if(type === 'view' && filename.indexOf(F.config.default_layout + '.html') > -1){ var sample = 'HI'; if(controller && controller.language === 'es') sample = 'HOLA'; return body.replace('
', sample + ''); }else{ return body; } });
It is a silly example... I use it to insert javascript code based on parameters like language, user login, ... There is no need to touch layout.html (in this case) so you can create self-contained modules (or similar) that modifies view contents on the fly.
You can always use modificators as usual just ignoring controller parameter on the corresponding function.
Hope it helps!
If available, the controller is passed to the modificator, so you can access its properties or set another ones depending on needs