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

273 lines
9.2 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>
Module: Sass::Callbacks
&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/Callbacks.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">Callbacks</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>Module: Sass::Callbacks
</h1>
<dl class="box">
<dt class="r1">Included in:</dt>
<dd class="r1"><span class='object_link'><a href="Plugin/Compiler.html" title="Sass::Plugin::Compiler (class)">Plugin::Compiler</a></span></dd>
<dt class="r2 last">Defined in:</dt>
<dd class="r2 last">.ruby-sass/lib/sass/callbacks.rb</dd>
</dl>
<div class="clear"></div>
<h2>Overview</h2><div class="docstring">
<div class="discussion">
<p>A lightweight infrastructure for defining and running callbacks. Callbacks
are defined using <span class='object_link'>#define_callback</span> at the class level, and called using
`run_#name` at the instance level.</p>
<p>Clients can add callbacks by calling the generated `on_#name` method, and
passing in a block that&#39;s run when the callback is activated.</p>
</div>
</div>
<div class="tags">
<div class="examples">
<p class="tag_title">Examples:</p>
<p class="example_title"><div class='inline'>
<p>Define a callback</p>
</div></p>
<pre class="example code"><code><span class='kw'>class</span> <span class='const'>Munger</span>
<span class='id identifier rubyid_extend'>extend</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'>Callbacks</span>
<span class='id identifier rubyid_define_callback'>define_callback</span> <span class='symbol'>:string_munged</span>
<span class='kw'>def</span> <span class='id identifier rubyid_munge'>munge</span><span class='lparen'>(</span><span class='id identifier rubyid_str'>str</span><span class='rparen'>)</span>
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='id identifier rubyid_str'>str</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>[a-z]</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>\1\1</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_run_string_munged'>run_string_munged</span> <span class='id identifier rubyid_str'>str</span><span class='comma'>,</span> <span class='id identifier rubyid_res'>res</span>
<span class='id identifier rubyid_res'>res</span>
<span class='kw'>end</span>
<span class='kw'>end</span></code></pre>
<p class="example_title"><div class='inline'>
<p>Use a callback</p>
</div></p>
<pre class="example code"><code><span class='id identifier rubyid_m'>m</span> <span class='op'>=</span> <span class='const'>Munger</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
<span class='id identifier rubyid_m'>m</span><span class='period'>.</span><span class='id identifier rubyid_on_string_munged'>on_string_munged</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_str'>str</span><span class='comma'>,</span> <span class='id identifier rubyid_res'>res</span><span class='op'>|</span> <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_str'>str</span><span class='embexpr_end'>}</span><span class='tstring_content'> was munged into </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_res'>res</span><span class='embexpr_end'>}</span><span class='tstring_content'>!</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span>
<span class='id identifier rubyid_m'>m</span><span class='period'>.</span><span class='id identifier rubyid_munge'>munge</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>bar</span><span class='tstring_end'>&quot;</span></span> <span class='comment'>#=&gt; bar was munged into bbaarr!</span></code></pre>
</div>
</div><h2>Defined Under Namespace</h2>
<p class="children">
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Callbacks/InstanceMethods.html" title="Sass::Callbacks::InstanceMethods (module)">InstanceMethods</a></span>
</p>
<h2>
Class Method Summary
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
</h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#extended-class_method" title="extended (class method)">.<strong>extended</strong>(base) &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Automatically includes <span class='object_link'><a href="Callbacks/InstanceMethods.html" title="Sass::Callbacks::InstanceMethods (module)">InstanceMethods</a></span> when something extends this
module.</p>
</div></span>
</li>
</ul>
<div id="class_method_details" class="method_details_list">
<h2>Class Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="extended-class_method">
.<strong>extended</strong>(base) &#x21d2; <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Automatically includes <span class='object_link'><a href="Callbacks/InstanceMethods.html" title="Sass::Callbacks::InstanceMethods (module)">InstanceMethods</a></span> when something extends this
module.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>base</span>
<span class='type'>(<tt>Module</tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
30
31
32</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '.ruby-sass/lib/sass/callbacks.rb', line 30</span>
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_extended'>extended</span><span class='lparen'>(</span><span class='id identifier rubyid_base'>base</span><span class='rparen'>)</span>
<span class='id identifier rubyid_base'>base</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='symbol'>:include</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="Callbacks/InstanceMethods.html" title="Sass::Callbacks::InstanceMethods (module)">InstanceMethods</a></span></span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Mon Oct 22 13:20:48 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>