Rails 3.2+ best practice for using Haml to generate Javascript templates (JST) - ruby-on-rails

I asked a specific question about problems I'm having with a specific gem intended to do this in a separate thread ( https://stackoverflow.com/q/18577033/1206117?sem=2 )
But I feel I may be on the "wrong boat" somehow because all of the questions I find about Rails/Haml/JST-templates are at least 2 years old, or go unanswered.
I'm writing an app with a lot of client-side JS and so want to use templates to render views (I'm using Backbone). I want to use Haml to write the templates.
I'm not looking for a debate about which gem/method is better, I'm looking for A WAY that works and has current support and active use. At present I cannot write my JS templates in Haml, and it's a bummer. I'm avoiding CoffeeScript at present since I'm still rather new to Javascript.

I've submitted an issue to the haml git repo.
https://github.com/haml/haml/issues/716

Looks like https://github.com/netzpirat/haml_coffee_assets gives you what you want. (window.JST templates, written in HAML, with inline coffescript support)

Related

What are the reasons to use erb integration for webpacker in Rails 6?

I have surfed a couple of hours through the web but couldn't find any articles/walkthroughs/comparisons touching erb integration of webpacker. I've found 1 question, unfortunately, the author haven't read docs attentively and the answer was right there, so - no any additional info there.
I have seen plenty of articles about vue and react, but nobody says a word about erb. However, it's quite clear why using react/vue/else similiar, it is not with erb.
The theme is quite vast and I expect a little hate towards me, so I'd ask two related questions (but if you have something to tell more about it - that's appreciated).
As I understand - it's vanilla (plain) js (maybe with a flavour of jQuery) caring just about dom and styling, with all the preprocessing made by rails. If it is so why not just continue using sprockets?
And what are the reasons to choose it instead of some react/vue/else framework?
You may use both : a vanilla JS framework (React, Vue ...) and some erb files. I find it interesting to setup my constant and other configuration variables within a .js.erb file that is generated by my Rails app when building the js app.
Things I like to put in this erb files :
schemas of my api, generated by my serializers
constants, like enum
values to be used in forms
To generalize, you can put anything owned by the backend that will not change at run time
this save you a couple API calls to retrieve this data. However, I tend to stop doing this as your JS app and Rails become tightly coupled and you can't use the sources of your JS app outside the Rails app

Sharing templates beetween JS and Rails using Haml + Mustache

I am trying to make common templates that used both by Rails and the client side, ie in coffescript.
I use hogan_assets and haml_assets to export templates to JS. However I can't find a way to use HAML and Mustache to render server-side views.
Partial solution is described here, but it doesn't work with view helpers, ie, "render partial" doesn't work.
For some unknown reason chaining of handlers, such as .mustache.haml, doesn't work, and I can't find neither good info on Rails template handler nor an example on how to build "chainable" handler.
I've been experimenting with something like smt_rails lately, but I have yet to find a silver bullet.

WYSIWYG recommendations for my Rails app

I'm working on a Rails project and I'm in need of a user-friendly WYSIWYG. I'll say this about the type of people using it: Whatever you think of as user-friendly, perhaps think one step below that (not an insult, just a realization).
Ideally, I'd like something where one could have basic functionality (lists, links, bold, italic) and see in real-time. Kind of like OH MY GOSH IT'S RIGHT HERE IN STACK OVERFLOW AS I CREATE THIS POST.
So, um, yeah: something like this would be excellent (although I'd prefer the windows be side-by-side rather than this editor-on-top situation, but I won't be picky).
I'd suggest to use gem ckeditor it's really perfect solution, i used it recently in my Rails 3.2 project
A pretty cool and fancy one is Sir Trevor JS. There is also a gem
We use TinyMCE quite a bit.
No unbelievable feature set or anything, but it does have a nice jQuery integration plugin (which goes a long way for us).
The live preview functionality seems very doable.
If your project is non commercial you can use this
Froala
I've been using Bootsy. It's simple and easy to use, however I have not been able to get the "image" upload => carrierwave to store on S3 servers. But everything else with it is fantastic.
Use Trix by Basecamp:
Trix is an open-source project from Basecamp, the creators of Ruby on Rails. Millions of people trust their text to Basecamp, and we built Trix to give them the best possible editing experience.
You can use Mercury its a full featured HTML5 editor
gem 'mercury-rails'
rails generate mercury:install
http://jejacks0n.github.io/mercury/
github: https://github.com/jejacks0n/mercury
Old question but check out froala: https://github.com/froala/wysiwyg-rails
and the plugins main homepage https://www.froala.com/wysiwyg-editor

Rails mixing templating languages

I'm working with a large project where the templates are written in erb. We're getting more and more into client side rendering of parts of the project and we have lots of exact duplicates in mustache of our erb templates.
I'd like to change the erb templates that are replicated in mustache to mustache and print the js templates out from those templates.
I haven't been able to figure out how to mix templating languages in rails though, is this possible? I'd rather not rewrite all the erb templates in mustache.
Thanks!
Maybe Isotope could be useful for you? I never tried it though.
I fear you'd have no direct solution...
An alternative:
You could reuse your good old html created by ruby if you insert in handlebars templates. But it's another js library...
http://www.handlebarsjs.com/

Free Rails 3 scaffold templates?

Does anyone know where I might be able to find free scaffold templates (i.e. .css files)? I'm doing a quick and dirty project, and I'm just looking for something generic, but a bit more visually appealing than the extremely generic default. Actually I'd be especially interested in something that look similar to the Django Admin section, but I'm not that picky, really.
Try this out: https://github.com/pilu/web-app-theme -- it's a basecamp/lighthouse type admin template (including css).
It'll work in both rails 2.3 and rails 3 -- the github readme has details.
I've used the Blueprint CSS Framework (http://www.blueprintcss.org/) for stuff like this in the past.

Resources