Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 373
- Log:
Initial import of Radiant 0.9.1, which is now packaged as a gem. This is an
import of the tagged 0.9.1 source checked out from GitHub, which isn't quite
the same as the gem distribution - but it doesn't seem to be available in an
archived form and the installed gem already has modifications, so this is
the closest I can get.
- Author:
- rool
- Date:
- Mon Mar 21 13:40:05 +0000 2011
- Size:
- 2400 Bytes
1 | require 'sass/tree/node' |
2 | |
3 | module Sass::Tree |
4 | # A static node representing a Sass comment (silent or loud). |
5 | # |
6 | # @see Sass::Tree |
7 | class CommentNode < Node |
8 | # The lines of text nested beneath the comment. |
9 | # |
10 | # @return [Array<Sass::Engine::Line>] |
11 | attr_accessor :lines |
12 | |
13 | # The text on the same line as the comment starter. |
14 | # |
15 | # @return [String] |
16 | attr_accessor :value |
17 | |
18 | # Whether or not the comment is silent (that is, doesn't output to CSS). |
19 | # |
20 | # @return [Boolean] |
21 | attr_accessor :silent |
22 | |
23 | # @param value [String] See \{#value} |
24 | # @param silent [Boolean] See \{#silent} |
25 | def initialize(value, silent) |
26 | @lines = [] |
27 | @value = value[2..-1].strip |
28 | @silent = silent |
29 | super() |
30 | end |
31 | |
32 | # Compares the contents of two comments. |
33 | # |
34 | # @param other [Object] The object to compare with |
35 | # @return [Boolean] Whether or not this node and the other object |
36 | # are the same |
37 | def ==(other) |
38 | self.class == other.class && value == other.value && silent == other.silent && lines == other.lines |
39 | end |
40 | |
41 | # Computes the CSS for the comment. |
42 | # |
43 | # Returns `nil` if this is a silent comment |
44 | # or the current style doesn't render comments. |
45 | # |
46 | # @overload to_s(tabs = 0) |
47 | # @param tabs [Fixnum] The level of indentation for the CSS |
48 | # @return [String, nil] The resulting CSS |
49 | # @see #invisible? |
50 | def to_s(tabs = 0, _ = nil) |
51 | return if invisible? |
52 | spaces = ' ' * (tabs - 1) |
53 | |
54 | content = (value.split("\n") + lines.map {|l| l.text}) |
55 | return spaces + "/* */" if content.empty? |
56 | content.map! {|l| (l.empty? ? "" : " ") + l} |
57 | content.first.gsub!(/^ /, '') |
58 | content.last.gsub!(%r{ ?\*/ *$}, '') |
59 | |
60 | spaces + "/* " + content.join(style == :compact ? '' : "\n#{spaces} *") + " */" |
61 | end |
62 | |
63 | # Returns `true` if this is a silent comment |
64 | # or the current style doesn't render comments. |
65 | # |
66 | # @return [Boolean] |
67 | def invisible? |
68 | style == :compressed || @silent |
69 | end |
70 | |
71 | protected |
72 | |
73 | # Removes this node from the tree if it's a silent comment. |
74 | # |
75 | # @param environment [Sass::Environment] The lexical environment containing |
76 | # variable and mixin values |
77 | # @return [Tree::Node, Array<Tree::Node>] The resulting static nodes |
78 | # @see Sass::Tree |
79 | def _perform(environment) |
80 | return [] if @silent |
81 | self |
82 | end |
83 | end |
84 | end |