简体   繁体   中英

Splitting element class into two classes html.slim in ruby on rails

noobie here: I have authentication method icons that I want to style separately, however they falls under the same class and I do not understand how to rewrite it to use two different for fb and google.

HTML SLIM code:

- if devise_mapping.omniauthable?
  .row
    .col-sm-12
      p.text-center.small-link= t('html.text.or_oauth_login')
      .col-sm-12.d-flex.justify-content-center.oauth-box
        - resource_class.omniauth_providers.each do |provider|
          a.tooltiptext.left[style="position:absolute; left: -10px; top: 43px; color: #FFFFFF;"]= t('html.links.tooltiptext')
          = link_to image_tag("#{provider}_logo.png", size: "40x40"), omniauth_authorize_path(resource_name, provider), class: "oauth-icon"

So the only class is "oauth-icon" . And I assume it takes #{provider} from devise.rb

config.omniauth :facebook, "xxxxxxxx", 
config.omniauth :google_oauth2, "xxxxxxxxxxx", "xxxxxxxxxx" {}

How should it be rewritten to have two classes?

您可以添加另一个动态创建的类,例如: class: "oauth-icon #{provider}-icon" ,这将使oauth-icon类保留在原处(我假设是必需的),然后添加一个facebook-icon类或google_oauth2-icon类,具体取决于提供者。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM