lundi 18 mai 2015

Rails erb vs gsub dynamic template

In my project, I am using the ERB as template engine. We have one page which used ERB template and it's loaded within 5-7 seconds.

The same page we changed it into dynamic template, the template values are stored in the database.

sample template <p> {{name}} </p> <p> {{address}} </p> <p> {{mobile number}} </p>

For applying the actual values over dynamic template, i have used the gsub. This case the same page takes load time as 16-20 seconds. I used 17 gsub over dynamic template.

How erb rendering is fast? (Because i am using the same content before and after dynamic template) Is there any way to increase the performance?

Note: Compared to 'gsub' method, 'sub' method is fast. But in my case i need to use global sub (gsub).

Aucun commentaire:

Enregistrer un commentaire