haml

How to use Javascript to manipulate modal content?

 ̄綄美尐妖づ 提交于 2019-12-30 14:20:16
问题 I am using bootstrap modals and Ruby on Rails. I was able to display the modal fine but I am having trouble using Javascript to manipulate the contents of the modal. I am not sure what I am doing wrong but I was not able to use Javascript to impact the contents of the modal at all, to the point that I started wondering if there are such a thing as different stack levels on the DOM elements or whether even the modal contents are part of the DOM. Here is my app/views/home/index.haml: - url =

Haml: link_to vs button_to

浪子不回头ぞ 提交于 2019-12-30 03:14:08
问题 From what I understand, link_to is used for get methods, and button_to is used for post methods. On the other hand, I was told that with HTML5 semantics, <button> is used for any type of clickable...well, button. In the case I have a clickable button that sends a user to a form to fill out, should I create a button_to or a link_to ? 回答1: It's simpler that you think. That methods are Rails helpers and don't have anything to do with haml. Yes, one method is for get and another for post methods.

How to send back js.haml in rails

▼魔方 西西 提交于 2019-12-29 11:45:13
问题 I have a rails create action which send back some jquery in a file: create.js.erb var appearance = $("<%= escape_javascript(render(:partial => @appearance)) %>").effect("highlight", {color: '#E6ff00'}, 2000); $("#sortable").append(appearance); $("#new_appearance")[0].reset(); I have started using HAML and want to know how I should be converting this. Can I use js.haml? If so what should the markup look like? 回答1: Actually, returning JS in HAML is pretty easy, just use the :plain filter and

Get absolute (base) url in sinatra

血红的双手。 提交于 2019-12-29 03:39:08
问题 Right now, I do a get '/' do set :base_url, "#{request.env['rack.url_scheme']}://#{request.env['HTTP_HOST']}" # ... haml :index end to be able to use options.base_url in the HAML index.haml. But I am sure there is a far better, DRY, way of doing this. Yet I cannot see, nor find it. (I am new to Sinatra :)) Somehow, outside of get , I don't have request.env available, or so it seems. So putting it in an include did not work. How do you get your base url? 回答1: A couple things. set is a class

regular expression in haml html attribute

ε祈祈猫儿з 提交于 2019-12-25 16:44:46
问题 Is posibble to have something like this? : %div{"data-regex": "a/regular/expression"} When I try to do this ways, I get this error: syntax error, unexpected ':', expecting tASSOC I tried this: %div{"data-regex": #{"a/regular/expression"}} , but is the same. 回答1: What you're probably looking for is: %div{data: {regex: "a/regular/expression"} } However it would be nice if you included the desired HTML in your question so we could know for sure. The other answer provided will also work, but this

Rendering Haml file in a javascript response with rails

那年仲夏 提交于 2019-12-25 08:49:22
问题 I am trying to render a haml file in a javascript response like so: $('#<%= @email.unique_name %> .preview .mail_content').html('<%=j render( :file => "user_mailer/#{@email.key}") %>'); An example of the file that would render is: - variables = { :contact_first_name => @contact.first_name, :user_full_name => @user.name, :user_first_name => @user.first_name } = @email.intro_html(variables) %p= "Please click the link below to go directly to the results of #{@user.first_name}'s assessment. You

Why delete method gives me wrong path? with

左心房为你撑大大i 提交于 2019-12-25 08:27:34
问题 I have simple delete link: = link_to "Delete", messages_path(message.id), :method => :delete Gives me error: No route matches [DELETE] "/messages.316" How to fix this? I have ruby 1.9.3p0 Rails 3.1.1 My routes.rb resources :messages do collection do get :outbox end end when i change this to message_path i recieve wrong number of arguments (0 for 1) -> full_trace: https://gist.github.com/1967988 -> all files: https://gist.github.com/1967994 outbox_messages GET /messages/outbox(.:format) {

How do I automatically generate static HTML from HAML with Sinatra or Padrino?

梦想的初衷 提交于 2019-12-25 08:15:55
问题 I want to serve static HTML pages using nginx . Then, I will use jQuery to update DIVs, SPANs, etc via AJAX calls from a Padrino server. I like creating my web pages in HAML because it's easier but in production, I don't want to serve HAML templates. Just raw, HTML at the speed of nginx. Is there an easy way to do this? What would be ideal would be a service that automatically renders HAML, partials, etc into the public folder that nginx could serve. 回答1: Simple, add padrino-cache to your app

unexpected indentation error with favicon_tag after migration to rails 5.0

北慕城南 提交于 2019-12-25 07:31:26
问题 With this HAML part !!! %html %head %title=document_title = favicon_link_tag 'logo16.png' %meta{content: form_authenticity_token, name: "csrf-token"}= '' ... I get the error SyntaxError: [stdin]:68:1: unexpected indentation So I played a bit with wrong Identation; then I get other but correct errors Inconsistent indentation: "\t\t " used for indentation, but the rest of the document was indented using 1 tab. Inconsistent indentation: "\t " used for indentation, but the rest of the document

NodeJS Express app generation with CoffeeScript and HAML

ε祈祈猫儿з 提交于 2019-12-25 02:26:45
问题 I just started looking into NodeJS and Express and found out about the possibility to generate a new app that uses hogan right from the start: express <appname> -c [stylus, less] --hogan --ejs Is there a way to generate a new app that uses CoffeeScript, HAML instead of Jade and Less/SCSS ? 回答1: I don't think there is a generator, but you can easily make an express app using HAML and coffeescript. package.json: { "name": "haml-coffee-express", "dependencies": { "express": "", "express-partials