O'Reilly logo

Rails, Angular, Postgres, and Bootstrap, 2nd Edition by David B. Copeland

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Storing View Templates in HTML Files

Currently, the view templates are strings inside our JavaScript. This might be okay if we have a single small view, but as we create more components and have to manage more views, it will be increasingly difficult to keep them as strings. The trailing backslashes and general clunkiness of managing view code in JavaScript is something that’s best to avoid.

Fortunately, Webpack makes this easy. With Angular 1, which was used in the previous edition of this book, you had to install a special Rails plugin to convert your templates into something the asset pipeline could serve up. Now, we need to bring in the HTML as a string and pass that string to the template: key when declaring our components. Doing this ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required