1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
65
  
66
  
67
  
68
  
69
  
70
  
71
  
72
  
73
  
74
  
75
  
76
  
77
  
78
  
79
  
80
  
81
  
82
  
83
  
84
  
85
  
86
  
87
  
88
  
89
  
90
  
91
  
92
  
93
  
94
  
95
  
96
  
97
  
98
  
99
  
100
  
101
  
102
  
103
  
104
  
105
  
106
  
107
  
108
  
109
  
110
  
111
  
112
  
113
  
114
  
115
  
116
  
117
  
118
  
119
  
120
  
121
  
122
  
123
  
/* 
  Author: Pontus Östlund <https://profiles.google.com/poppanator> 
*/ 
//! Sass is a scripting language that is interpreted into Cascading Style 
//! Sheets (CSS). This module is a glue for @tt{libsass@}. 
//! 
//! @seealso 
//!  SASS @url{http://sass-lang.com/@} 
 
#pike __REAL_VERSION__ 
#require constant(Tools@module@) 
 
inherit Tools@module@; 
 
//! SCSS compiler 
//! 
//! @example 
//! @code 
//! Tools.Sass.SCSS compiler = Tools.Sass.SCSS(); 
//! // Minify the output and create a source map file. 
//! compiler->set_options(([ 
//!   "output_style" : Tools.Sass.STYLE_COMPRESSED 
//!   "source_map_file" : "path/to/write/source.map" 
//! ])); 
//! 
//! if (mixed e = catch(compiler->compile_file("input.scss", "output.css"))) { 
//!   werror("Failed compiling input.scss to output.css\n"); 
//! } 
//! @endcode 
class SCSS 
{ 
  inherit Tools@module@.Api; 
 
  //! Set options to the SASS compiler. @[opts] 
  //! 
  //! @param opts 
  //!  @mapping 
  //!   @member int "output_style" 
  //!    Any of the @[STYLE_NESTED], @[STYLE_EXPANDED], @[STYLE_COMPACT] 
  //!    or @[STYLE_COMPRESSED] constants. See also @[set_output_style()]. 
  //!   @member string "include_path" 
  //!    Path to root of incude files. See also @[set_include_path()]. 
  //!   @member string "source_map_file" 
  //!    File to write source map file to. Only has effect in @[compile_file()]. 
  //!    See also @[set_source_map_file()]. 
  //!   @member bool "source_comments" 
  //!    Turn on/off comments in the output containing info about the source 
  //!    file - line numbers and such. Default of @tt{false@}. See also 
  //!    @[set_source_comments()]. 
  //!   @member bool "source_map_embed" 
  //!    Turn on/off if a source map should be embedded in the output or not. 
  //!    Default is @tt{false@}. See also @[set_source_map_embed()]. 
  //!  @endmapping 
  void set_options(mapping(string:string|int) opts) 
  { 
    foreach (opts; string opt; string|int val) { 
      switch (opt) 
      { 
        case "output_style": 
          if (!intp(val)) { 
            error("Value to set_output_style() must be an integer!\n"); 
          } 
          set_output_style(val); 
          break; 
 
        case "include_path": 
          if (!stringp(val)) { 
            error("Value to set_include_path() must be a string!\n"); 
          } 
          set_include_path(val); 
          break; 
 
        case "source_map_file": 
          if (!stringp(val)) { 
            error("Value to set_source_map_file() must be a string!\n"); 
          } 
          set_source_map_file(val); 
          break; 
 
        case "source_map_embed": 
          if (!intp(val)) { 
            error("Value to set_source_map_embed() must be an int(0..1)!\n"); 
          } 
          set_source_map_embed(val); 
          break; 
 
        case "source_map_root": 
          if (!stringp(val)) { 
            error("Value to set_source_map_root() must be a string!\n"); 
          } 
          set_source_map_root(val); 
          break; 
 
        case "omit_source_map": 
          if (!intp(val)) { 
            error("Value to set_omit_source_map_url() must be an integer!\n"); 
          } 
          set_omit_source_map_url(val); 
          break; 
 
        case "source_comments": 
          if (!intp(val)) { 
            error("Value to set_source_comments() must be an integer!\n"); 
          } 
          set_source_comments(val); 
          break; 
 
        default: 
          error("Unknown option %O!\n", opt); 
      } 
    } 
  } 
 
  // //! Test if @[set_options()] will be linked to from @[a]? 
  // //! 
  // //! @param a 
  // //!  Just a parameter 
  // void test_func(mapping a) 
  // { 
  //   return a; 
  // } 
}