sass-site/source/documentation/Sass/CSS.html
2018-10-22 14:13:05 -07:00

729 lines
21 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
Class: Sass::CSS
&mdash; Documentation by YARD 0.9.12
</title>
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="../../assets/css/docs.css" type="text/css" charset="utf-8" />
<script type="text/javascript" charset="utf-8">
hasFrames = window.top.frames.main ? true : false;
relpath = '../';
framesUrl = "../frames.html#!Sass/CSS.html";
</script>
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
</head>
<body>
<div id="header">
<div id="menu">
<a href="../_index.html">Index (C)</a> &raquo;
<span class='title'><span class='object_link'><a href="../Sass.html" title="Sass (module)">Sass</a></span></span>
&raquo;
<span class="title">CSS</span>
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>
<div id="search">
<a class="full_list_link" id="class_list_link"
href="../class_list.html">
Class List
</a>
<a class="full_list_link" id="method_list_link"
href="../method_list.html">
Method List
</a>
<a class="full_list_link" id="file_list_link"
href="../file_list.html">
File List
</a>
</div>
<div class="clear"></div>
</div>
<iframe id="search_frame"></iframe>
<div id="content"><h1>Class: Sass::CSS
</h1>
<dl class="box">
<dt class="r1">Inherits:</dt>
<dd class="r1">
<span class="inheritName">Object</span>
<ul class="fullTree">
<li>Object</li>
<li class="next">Sass::CSS</li>
</ul>
<a href="#" class="inheritanceTree">show all</a>
</dd>
<dt class="r2 last">Defined in:</dt>
<dd class="r2 last">.ruby-sass/lib/sass/css.rb</dd>
</dl>
<div class="clear"></div>
<h2>Overview</h2><div class="docstring">
<div class="discussion">
<p>This class converts CSS documents into Sass or SCSS templates. It works by
parsing the CSS document into a <span class='object_link'><a href="Tree.html" title="Sass::Tree (module)">Tree</a></span> structure, and then applying
various transformations to the structure to produce more concise and
idiomatic Sass/SCSS.</p>
<p>Example usage:</p>
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="../Sass.html" title="Sass (module)">Sass</a></span></span><span class='op'>::</span><span class='const'>CSS</span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="#initialize-instance_method" title="Sass::CSS#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>p { color: blue }</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_render'><span class='object_link'><a href="#render-instance_method" title="Sass::CSS#render (method)">render</a></span></span><span class='lparen'>(</span><span class='symbol'>:sass</span><span class='rparen'>)</span> <span class='comment'>#=&gt; &quot;p\n color: blue&quot;
</span><span class='const'><span class='object_link'><a href="../Sass.html" title="Sass (module)">Sass</a></span></span><span class='op'>::</span><span class='const'>CSS</span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="#initialize-instance_method" title="Sass::CSS#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>p { color: blue }</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_render'><span class='object_link'><a href="#render-instance_method" title="Sass::CSS#render (method)">render</a></span></span><span class='lparen'>(</span><span class='symbol'>:scss</span><span class='rparen'>)</span> <span class='comment'>#=&gt; &quot;p {\n color: blue; }&quot;
</span></code></pre>
</div>
</div>
<div class="tags">
</div>
<h2>
Instance Method Summary
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
</h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(template, options = {}) &#x21d2; CSS </a>
</span>
<span class="note title constructor">constructor</span>
<span class="summary_desc"><div class='inline'>
<p>A new instance of CSS.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#render-instance_method" title="#render (instance method)">#<strong>render</strong>(fmt = :sass) &#x21d2; String </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Converts the CSS template into Sass or SCSS code.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#source_encoding-instance_method" title="#source_encoding (instance method)">#<strong>source_encoding</strong> &#x21d2; Encoding<sup>?</sup> </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Returns the original encoding of the document.</p>
</div></span>
</li>
</ul>
<div id="constructor_details" class="method_details_list">
<h2>Constructor Details</h2>
<div class="method_details first">
<h3 class="signature first" id="initialize-instance_method">
#<strong>initialize</strong>(template, options = {}) &#x21d2; <tt><span class='object_link'><a href="" title="Sass::CSS (class)">CSS</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns a new instance of CSS</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>template</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The CSS stylesheet. This stylesheet can be encoded using any encoding that
can be converted to Unicode. If the stylesheet contains an `@charset`
declaration, that overrides the Ruby encoding (see
<a href="../file.SASS_REFERENCE.html#Encodings" title="the encoding documentation">the encoding documentation</a>)</p>
</div>
</li>
<li>
<span class='name'>options</span>
<span class='type'>(<tt>Hash</tt>)</span>
<em class="default">(defaults to: <tt>{}</tt>)</em>
&mdash;
<div class='inline'>
<p>a customizable set of options</p>
</div>
</li>
</ul>
<p class="tag_title">Options Hash (<tt>options</tt>):</p>
<ul class="option">
<li>
<span class="name">:old</span>
<span class="type">(<tt>Boolean</tt>)</span>
<span class="default">
&mdash; default:
<tt>false</tt>
</span>
&mdash; <div class='inline'>
<p>Whether or not to output old property syntax (`:color blue` as opposed to
`color: blue`). This is only meaningful when generating Sass code, rather
than SCSS.</p>
</div>
</li>
<li>
<span class="name">:indent</span>
<span class="type">(<tt>String</tt>)</span>
<span class="default">
&mdash; default:
<tt>&quot; &quot;</tt>
</span>
&mdash; <div class='inline'>
<p>The string to use for indenting each line. Defaults to two spaces.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
29
30
31
32
33
34
35
36
37
38
39</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '.ruby-sass/lib/sass/css.rb', line 29</span>
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_template'>template</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
<span class='kw'>if</span> <span class='id identifier rubyid_template'>template</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>IO</span>
<span class='id identifier rubyid_template'>template</span> <span class='op'>=</span> <span class='id identifier rubyid_template'>template</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span>
<span class='kw'>end</span>
<span class='ivar'>@options</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='symbol'>:_convert</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='rparen'>)</span>
<span class='comment'># Backwards compatibility
</span> <span class='ivar'>@options</span><span class='lbracket'>[</span><span class='symbol'>:old</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>true</span> <span class='kw'>if</span> <span class='ivar'>@options</span><span class='lbracket'>[</span><span class='symbol'>:alternate</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='kw'>false</span>
<span class='ivar'>@template</span> <span class='op'>=</span> <span class='id identifier rubyid_template'>template</span>
<span class='ivar'>@checked_encoding</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
<div id="constructor_details" class="method_details_list">
<h2>Constructor Details</h2>
<div class="method_details first">
<h3 class="signature first" id="initialize-instance_method">
#<strong>initialize</strong>(template, options = {}) &#x21d2; <tt><span class='object_link'><a href="" title="Sass::CSS (class)">CSS</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns a new instance of CSS</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>template</span>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The CSS stylesheet. This stylesheet can be encoded using any encoding that
can be converted to Unicode. If the stylesheet contains an `@charset`
declaration, that overrides the Ruby encoding (see
<a href="../file.SASS_REFERENCE.html#Encodings" title="the encoding documentation">the encoding documentation</a>)</p>
</div>
</li>
<li>
<span class='name'>options</span>
<span class='type'>(<tt>Hash</tt>)</span>
<em class="default">(defaults to: <tt>{}</tt>)</em>
&mdash;
<div class='inline'>
<p>a customizable set of options</p>
</div>
</li>
</ul>
<p class="tag_title">Options Hash (<tt>options</tt>):</p>
<ul class="option">
<li>
<span class="name">:old</span>
<span class="type">(<tt>Boolean</tt>)</span>
<span class="default">
&mdash; default:
<tt>false</tt>
</span>
&mdash; <div class='inline'>
<p>Whether or not to output old property syntax (`:color blue` as opposed to
`color: blue`). This is only meaningful when generating Sass code, rather
than SCSS.</p>
</div>
</li>
<li>
<span class="name">:indent</span>
<span class="type">(<tt>String</tt>)</span>
<span class="default">
&mdash; default:
<tt>&quot; &quot;</tt>
</span>
&mdash; <div class='inline'>
<p>The string to use for indenting each line. Defaults to two spaces.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
29
30
31
32
33
34
35
36
37
38
39</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '.ruby-sass/lib/sass/css.rb', line 29</span>
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_template'>template</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
<span class='kw'>if</span> <span class='id identifier rubyid_template'>template</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>IO</span>
<span class='id identifier rubyid_template'>template</span> <span class='op'>=</span> <span class='id identifier rubyid_template'>template</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span>
<span class='kw'>end</span>
<span class='ivar'>@options</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='symbol'>:_convert</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='rparen'>)</span>
<span class='comment'># Backwards compatibility
</span> <span class='ivar'>@options</span><span class='lbracket'>[</span><span class='symbol'>:old</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>true</span> <span class='kw'>if</span> <span class='ivar'>@options</span><span class='lbracket'>[</span><span class='symbol'>:alternate</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='kw'>false</span>
<span class='ivar'>@template</span> <span class='op'>=</span> <span class='id identifier rubyid_template'>template</span>
<span class='ivar'>@checked_encoding</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
<div id="instance_method_details" class="method_details_list">
<h2>Instance Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="render-instance_method">
#<strong>render</strong>(fmt = :sass) &#x21d2; <tt>String</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Converts the CSS template into Sass or SCSS code.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>fmt</span>
<span class='type'>(<tt>Symbol</tt>)</span>
<em class="default">(defaults to: <tt>:sass</tt>)</em>
&mdash;
<div class='inline'>
<p>`:sass` or `:scss`, designating the format to return.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>String</tt>)</span>
&mdash;
<div class='inline'>
<p>The resulting Sass or SCSS code</p>
</div>
</li>
</ul>
<p class="tag_title">Raises:</p>
<ul class="raise">
<li>
<span class='type'>(<tt><span class='object_link'><a href="SyntaxError.html" title="Sass::SyntaxError (class)">Sass::SyntaxError</a></span></tt>)</span>
&mdash;
<div class='inline'>
<p>if there&#39;s an error parsing the CSS template</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
46
47
48
49
50
51
52</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '.ruby-sass/lib/sass/css.rb', line 46</span>
<span class='kw'>def</span> <span class='id identifier rubyid_render'>render</span><span class='lparen'>(</span><span class='id identifier rubyid_fmt'>fmt</span> <span class='op'>=</span> <span class='symbol'>:sass</span><span class='rparen'>)</span>
<span class='id identifier rubyid_check_encoding!'>check_encoding!</span>
<span class='id identifier rubyid_build_tree'>build_tree</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>to_</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_fmt'>fmt</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='ivar'>@options</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\n</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>rescue</span> <span class='const'><span class='object_link'><a href="../Sass.html" title="Sass (module)">Sass</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="SyntaxError.html" title="Sass::SyntaxError (class)">SyntaxError</a></span></span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_err'>err</span>
<span class='id identifier rubyid_err'>err</span><span class='period'>.</span><span class='id identifier rubyid_modify_backtrace'>modify_backtrace</span><span class='lparen'>(</span><span class='symbol'>:filename</span> <span class='op'>=&gt;</span> <span class='ivar'>@options</span><span class='lbracket'>[</span><span class='symbol'>:filename</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>(css)</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_raise'>raise</span> <span class='id identifier rubyid_err'>err</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="source_encoding-instance_method">
#<strong>source_encoding</strong> &#x21d2; <tt>Encoding</tt><sup>?</sup>
</h3><div class="docstring">
<div class="discussion">
<p>Returns the original encoding of the document.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Encoding</tt>, <tt>nil</tt>)</span>
</li>
</ul>
<p class="tag_title">Raises:</p>
<ul class="raise">
<li>
<span class='type'>(<tt>Encoding::UndefinedConversionError</tt>)</span>
&mdash;
<div class='inline'>
<p>if the source encoding cannot be converted to UTF-8</p>
</div>
</li>
<li>
<span class='type'>(<tt>ArgumentError</tt>)</span>
&mdash;
<div class='inline'>
<p>if the document uses an unknown encoding with `@charset`</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
60
61
62
63</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '.ruby-sass/lib/sass/css.rb', line 60</span>
<span class='kw'>def</span> <span class='id identifier rubyid_source_encoding'>source_encoding</span>
<span class='id identifier rubyid_check_encoding!'>check_encoding!</span>
<span class='ivar'>@original_encoding</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Mon Oct 22 13:20:51 2018 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.12 (ruby-2.5.3).
</div>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-535380-14', 'sass-lang.com');
ga('send', 'pageview');
</script>
</body>
</html>