Understanding How to Pass Variables Described in a Slim File to sass

Asked 2 years ago, Updated 2 years ago, 86 views

Nice to meet you.

Prototyping with Slim+sass+middleman.
Does anyone know how to refer to the variables defined in Slim in SAS SCSS when describing SAS SCSS in a Slim file?
H I remember doing the same thing with Haml…

As an example, I would like to do the following:

Thank you for your cooperation.

Define variables in //slim
- height = 177.0
- width = Time.now.min
.rectangle

sass:
  .rectangle
    Invoke variables with //ass
    height —$height
    width —$width

sass slim-lang

2022-09-30 20:51

1 Answers

I don't think I can.
Isn't there no choice but to finish with a slim?

[slim]

-height=177.0
- width = Time.now.min

.rectangle style="height:#{height};width:#{width};"

Or using jQuery

[slim+jQuery]

-height=177.0
- width = Time.now.min

.rectangle

javascript:
  $(document).ready(function(){$('.rectangle').css({'height':#{height},'width':#{width}});});

However, for middleman in the above example, width is the value at the time of build, so it does not change dynamically, and I have doubts about the time.now.min using slim.If you want to change the width value dynamically depending on the time, isn't it necessary to calculate the width value in JavaScript?


2022-09-30 20:51

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.