slim-lang

Conditional class in slim with 3 conditions

六月ゝ 毕业季﹏ 提交于 2021-01-28 22:17:43
问题 I would like to write conditional class in slim but I only know how to do it with 2 conditions, like : div class=(index == 0 ? 'class1' : 'class1 class3') How to do it with three conditions? - if index == 0 .class1 - elsif index == -1 .class2.class3 - else .class1.class3 回答1: div class=(if index == 0 then 'class1' elsif index == -1 then 'class2 class3' else '.class1 class3' end) 来源: https://stackoverflow.com/questions/40591084/conditional-class-in-slim-with-3-conditions

YouTube API onPlayerReady is Never Getting Called

孤者浪人 提交于 2020-02-07 14:55:48
问题 Follow this tutorial, I have been trying to integrate the YouTube API into my website. Specifically, when a button is pressed I want to play a video hosted on YouTube in fullscreen mode. Unfortunately, I can't even get the code given in that tutorial to work. I'm using Slim for markup so I added an empty div with the ID of player as the tutorial suggests .body .player I then added this javascript at the end of my markup $(document).ready( function() { loadYoutubeAPI(); }); Which should start

Why can't show restaurant list?

喜欢而已 提交于 2020-01-09 12:05:10
问题 I'm trying to make some restaurant list. I associated two tables, and then write this code. class Restaurant < ActiveRecord::Base has_many :restaurant_translations end class RestaurantTranslation < ActiveRecord::Base self.table_name = 'restaurant_translations' end restaurant_controller.rb class RestaurantController < ApplicationController def list @restaurants = Restaurant.all logger.debug @restaurants end end list.html.slim table thead tr th Type th Name th Url th Genre th Addr tbody -

simple_form 'form-inline' not working

放肆的年华 提交于 2020-01-04 06:05:20
问题 I'm trying to make two input (firstname and lastname) to next to each other. Here is my code and it's currently just showing two big rows of input window. = simple_form_for @user, html: {class: 'form-inline'} do |f| = f.fields_for :profile, @user.profile || Profile.new, html: {class: 'form-inline'} do |p| .form-1 .form-1-detail .input-text = f.input :last_name, required: true .input-text = f.input :first_name, required: true I'm now sure how to make them to display inline. Can anyone help me?

simple_form 'form-inline' not working

别说谁变了你拦得住时间么 提交于 2020-01-04 06:03:20
问题 I'm trying to make two input (firstname and lastname) to next to each other. Here is my code and it's currently just showing two big rows of input window. = simple_form_for @user, html: {class: 'form-inline'} do |f| = f.fields_for :profile, @user.profile || Profile.new, html: {class: 'form-inline'} do |p| .form-1 .form-1-detail .input-text = f.input :last_name, required: true .input-text = f.input :first_name, required: true I'm now sure how to make them to display inline. Can anyone help me?

How to render HTML inside Slim templates

醉酒当歌 提交于 2020-01-01 04:13:47
问题 I'm trying to render a link preceded by an icon. I'm using Slim templating engine along with Bootstrap CSS. Usually you could do this the following way: <a href="#"><i class="icon-user"></i> My Profile</a> According to Slim's documentation, we can use == to render without escaping HTML. So, translating this to Slim, I tried the following variations: li== link_to "<i class='icon-user'></i> My Profile", current_user li== link_to "#{'<i class="icon-user"></i>'.html_safe} My Profile", current

Links do not work after translation into slim format

梦想与她 提交于 2019-12-25 00:00:09
问题 I have an html code with rails. I need to translate it into slim format, I changed the file format, translated it with a convector and tried to run it as a result the links do not work, can you tell me why? head.html.erb <section id="header"> <div class='navigation-panel'> <button class='burger-button' id='header-burger-button container' onclick='burgerAction()'> <%= image_tag("header/burger.png") %> </button> <button class='contact-us-button burger-hidable container' onclick='scroller(

rails slim indent syntax error

亡梦爱人 提交于 2019-12-24 07:17:53
问题 I am trying to design my sites EULA page content and I keep receiving this error: Are you trying to nest a child tag in a tag containing text? Use | for the text block! It seems that all my indents are fine and yet this doesnt work: v#page_content .container = render 'leftbar' .content = render 'actions' .maincol h2 Corp End User License Agreement h7 Last Revised: September 20, 2012 ol li h2 u Introduction | Welcome to the Corp platform at a href="http://www.Corp.com" www.Corp.com | owned and

Custom Javascript type with Rails and Slim

二次信任 提交于 2019-12-23 18:54:19
问题 In Rails, both the javascript_tag and javascript_include_tag render the type attribute as type="text/javascript" I need to customize this attribute. Our application uses Slim syntax which makes this a little more difficult. script src="mathjax_config" type="text/x-mathjax-config" ^ doesn't error but doesn't even include the file javascript_tag[type="text/x-mathjax-config"] javascript code here ^ throws an error I'm hoping to avoid breaking the file away from slim. Ruby version 1.9.3 Rails

Slim templates - removing whitespaces around the block tag

眉间皱痕 提交于 2019-12-23 13:59:41
问题 I'm trying Slim templates in a new project (after using Haml for quite a while). While overall experience is great, I've run into a problem with spaces being always inserted around tags which normally use display: block Say, ul.ampm li.am am li.pm pm generates <ul class="ampm"> <li class="am"> am </li> <li class="pm"> pm </li> </ul> while .ampm span.am am span.pm pm generates <div class="ampm"> <span class="am">am</span></span class="pm">pm</span> </div> Normally it's not a big issue, but we