Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print sass variables #38

Open
mmintel opened this issue Feb 12, 2014 · 7 comments
Open

Print sass variables #38

mmintel opened this issue Feb 12, 2014 · 7 comments
Assignees
Labels

Comments

@mmintel
Copy link

mmintel commented Feb 12, 2014

Hello,

I don't know if thats technically possible, but it would be reeeally cool if I could "print " variables in my comments. I can't do that with Sass alone because comments are not compiled.

What I want to use is the following
/*
# Test
Use #{$buttonClass} for a button. The primary color is #{$colorPrimary}
*/

Greetings

@winstromming winstromming self-assigned this Feb 12, 2014
@winstromming
Copy link
Owner

@mmintel I've also considered adding this. It involves quite a bit of work (or heavy regex) because, as you say, Sassdown does not actually compile the Sass itself. Marking this as a future feature for now, though.

@m5o
Copy link
Contributor

m5o commented Feb 14, 2014

This is technically possible. Sass can interpolate strings in comments, but they will only print out to a string when compiling to CSS and using the CSS comments /* */

Test this code online with http://sassmeister.com/

$buttonClass: 'btn';
$colorPrimary: #FF0;

/*
# Test
Use #{$buttonClass} for a button. The primary color is #{$colorPrimary}
*/

// not working with single line comments #{$buttonClass}

@winstromming
Copy link
Owner

Yep, it's possible - just need to investigate and get around to it.

@idflood
Copy link

idflood commented Apr 10, 2014

Hi, I wanted to make a new issue with a pull request but I think this may solve partially this issue.

When following BEM syntax we frequently add modifiers to the same html structure. For example a simple button may have many 'color' variants:

<a href="#" class="button button--yellow">yellow</a>
<a href="#" class="button button--purple">purple</a>
<a href="#" class="button button--submarine">submarine</a>
<a href="#" class="button button--rain">rain</a>
<a href="#" class="button button--fog">fog</a>
...

If we compile the result we can simplify this with the addition of a 'split' handlebar helpers.

{{#each (split "yellow, purple, submarine, rain, fog")}}
  <a href="#" class="button button--{{this}}">{{this}}</a>
{{/each}}

Compiling the result eventually become even more interesting with more complicated structures.

{{#each (split "status, success, warning, error")}}
  <div class="message message--{{this}}">
    Message type "{{this}}" example.
    <a href="#" class="message__close"><i class="icon icon--close"></i></a>
  </div>
{{/each}}

Now, I'm not 100% sure this would help with this specific issue. Let me know if I need to adapt my changes or make a different pull request.

@mmintel
Copy link
Author

mmintel commented Apr 21, 2014

Is there any kind of workaround until this is implemented? I am really missing this feature =( I tried to use the compiled .css file for sassdown but then I am losing the navigation because there is just one file

@winstromming
Copy link
Owner

@mmintel Sorry, not yet. You could have a look at the pull request by @idflood (idflood@536a129). I've not had the time to work on this for a while, but it's still on the list.

@AdrianoCahete
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants