开发者

In SASS, is there a way to define for #{$site_name}-product-list? (ID name using a variable)

For example, if

$site_name is cars, or boats, then something like

#{$site_name}-product-list
  background: #ffc

which will become

#cars-product-list
  background: #ffc        // this is still SASS, but the CSS will be like this

is it possible in SASS? (we are not using SCSS, so looking for a solution for SASS, but if SCSS can do it, can you put that in a comment. thanks.) (HAML can do this by using %div{:id => "#{site_name}-product-list"}, but need the SASS to work with it as 开发者_Go百科well)


Ok, I found the answer:

http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#interpolation_

so it can be

$site_name: cars

  ...

##{$site_name}-product-list
  background: #ffc

which will become

#cars-product-list
  background: #ffc

although, there are some users who claim that it is useless to use an ID or class names like that to help boost the search engine rankings... such they claim that it is 100% as good to just use #product-list -- but my question remain -- how can we be sure about all of Google, Yahoo, Bing, do that? And what applies today may not apply 2 months later? (they can change the algorithm any time)

Also, this needs to be done for both the HAML as well as for the SASS files (for a lot of elements, not just 1 or 2 -- probably around 20 for HAML and 20 for SASS (either singular or plural)), so I wonder if it is worth the effort.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜