无法在SASS中编译注释
我正在使用Mac10.7.2、Ruby 1.9.3和SASS 3.2.1。我正在尝试获取多行注释和多级CSS之间的注释。我知道我们可以在SASS中实现多行评论,如下所示: SASS无法在SASS中编译注释,sass,Sass,我正在使用Mac10.7.2、Ruby 1.9.3和SASS 3.2.1。我正在尝试获取多行注释和多级CSS之间的注释。我知道我们可以在SASS中实现多行评论,如下所示: SASS /* Multiline comments goes here /* Multiline * comments * goes here */ /* --------------------------------------- ----------------------------------
/*
Multiline
comments
goes here
/* Multiline
* comments
* goes here */
/*
---------------------------------------
---------------------------------------
--- Table of Contents: ---
--- ---
--- 1. DEFAULT ELEMENTS ---
--- 2. LINKS ---
--- 3. TABLE ---
--- 4. FORM ---
--- 5. GLOBAL CLASSES ---
---------------------------------------
---------------------------------------
/* ---------------------------------------
* ---------------------------------------
* --- Table of Contents: ---
* --- ---
* --- 1. DEFAULT ELEMENTS ---
* --- 2. LINKS ---
* --- 3. TABLE ---
* --- 4. FORM ---
* --- 5. GLOBAL CLASSES ---
* ---------------------------------------
* --------------------------------------- */
CSS
/*
Multiline
comments
goes here
/* Multiline
* comments
* goes here */
/*
---------------------------------------
---------------------------------------
--- Table of Contents: ---
--- ---
--- 1. DEFAULT ELEMENTS ---
--- 2. LINKS ---
--- 3. TABLE ---
--- 4. FORM ---
--- 5. GLOBAL CLASSES ---
---------------------------------------
---------------------------------------
/* ---------------------------------------
* ---------------------------------------
* --- Table of Contents: ---
* --- ---
* --- 1. DEFAULT ELEMENTS ---
* --- 2. LINKS ---
* --- 3. TABLE ---
* --- 4. FORM ---
* --- 5. GLOBAL CLASSES ---
* ---------------------------------------
* --------------------------------------- */
但我在样式表中使用不同的注释来突出/识别CSS中的多个级别和不同的内容,其中两个如下:
我的样式表以下面的注释开始:
/***************************************************************
Theme Name: Theme name goes here
Theme URI: Theme URL goes here
Description: Discription related to theme will goes here
Version: 1.1
Author: Author name goes here
Author URI: Authour url goes here
***************************************************************/
我的应用程序索引注释如下:
/*
---------------------------------------
---------------------------------------
--- Table of Contents: ---
--- ---
--- 1. HEADER ---
--- -1.1 Navigation Bar ---
--- ---
--- ---
--- 2. MAIN SECTION ---
--- -2.1 Home page ---
--- --2.1.1 Sections ---
--- ---2.1.1.1 sub section ---
--- ---
--- ---
--- 3. FOOTER ---
---------------------------------------
---------------------------------------
*/
我可以找到更接近它的注释,但不能准确地将其作为已编译的CSS注释
SASS
/*
Multiline
comments
goes here
/* Multiline
* comments
* goes here */
/*
---------------------------------------
---------------------------------------
--- Table of Contents: ---
--- ---
--- 1. DEFAULT ELEMENTS ---
--- 2. LINKS ---
--- 3. TABLE ---
--- 4. FORM ---
--- 5. GLOBAL CLASSES ---
---------------------------------------
---------------------------------------
/* ---------------------------------------
* ---------------------------------------
* --- Table of Contents: ---
* --- ---
* --- 1. DEFAULT ELEMENTS ---
* --- 2. LINKS ---
* --- 3. TABLE ---
* --- 4. FORM ---
* --- 5. GLOBAL CLASSES ---
* ---------------------------------------
* --------------------------------------- */
CSS
/*
Multiline
comments
goes here
/* Multiline
* comments
* goes here */
/*
---------------------------------------
---------------------------------------
--- Table of Contents: ---
--- ---
--- 1. DEFAULT ELEMENTS ---
--- 2. LINKS ---
--- 3. TABLE ---
--- 4. FORM ---
--- 5. GLOBAL CLASSES ---
---------------------------------------
---------------------------------------
/* ---------------------------------------
* ---------------------------------------
* --- Table of Contents: ---
* --- ---
* --- 1. DEFAULT ELEMENTS ---
* --- 2. LINKS ---
* --- 3. TABLE ---
* --- 4. FORM ---
* --- 5. GLOBAL CLASSES ---
* ---------------------------------------
* --------------------------------------- */
有时我们还需要多层次的评论
.firstLavel
background: #f00
/* comeent goes here before second level */
.secondLavel
font-size: 20
color: #ddd
/* comeent goes here before third level
.secondLavel
font-size: 70
color: #ded
但我得到的结果是:
background: red;
/* comeent goes here before second level */
/* comeent goes here before third level */ }
.firstLavel .secondLavel {
font-size: 20;
color: #dddddd; }
.firstLavel .secondLavel {
font-size: 70;
color: #ddeedd; }
应该是:
.firstLavel {
background: red; }
/* comment goes here before second level */
.firstLavel .secondLavel {
font-size: 20;
color: #dddddd; }
/* comment goes here before third level */
.firstLavel .secondLavel {
font-size: 70;
color: #ddeedd; }
Sass使用一种算法进行编译,该算法递归地呈现CSS树的所有子级,从端点(没有更深层次的端点)开始。 由于该算法,当注释不是端点时,无法在子对象之前设置注释:注释永远不会有更深层次。。设置注释的唯一方法是将注释设置为节点的子级
澄清,考虑这棵树:
root
child1
child1.1
/* comment on 1.1*/
child1.1.1
child1.2
child2
/* comment on 2 */
child3
/* comment on 3*/
child3.1
child4
渲染它将首先生成没有子项的条目,然后生成更深的条目。
CSS的顺序为:
root
child2
/* comment on 2 */
child4
child1
child1.2
child1.1
/* comment on 1.1 */
child1.1.1
child3
/* comment on 3 */
child3.1
使用的算法是一个队列,它将端点放在第一位这只是一个问题,既然所有生产CSS都应该缩小,那么为什么不使用
/
Sass注释,这样您可以为自己和您的团队提供注释,但您的用户不必下载它们?是的,我完全同意,但在我的例子中,我希望在我的应用程序中保留这两个选项,并在生产中使用minified。有时我的团队或其他人没有Ruby或SASS编译器。因此,他们至少可以在CSS中进行更改。他们对CSS所做的任何更改都将在下次编译时被覆盖。如果你想使用Sass,你需要船上的每个人。你能使用SCSS语法吗?是的,它有点糟糕。。您可以随时帮助开发SASS并添加注释功能;)SAS有自己的意见,这对于将来的维护非常有用。但我正在寻找CSS注释,因为万一将来有人在处理它,就不要使用ruby编译器。在这种情况下,他/她可以使用未压缩的CSS。