pike.git / module.pmod.in

version» Context lines:

pike.git/module.pmod.in:8:   //! @seealso   //! SASS @url{http://sass-lang.com/@}      #pike __REAL_VERSION__   #require constant(Tools@module@)      //! @ignore   inherit Tools@module@;   //! @endignore    - //! SCSS compiler + //! Sass/SCSS compiler.   //! -  + //! @note + //! @b{Some notes on the @tt{*_include_*@} stuff.@} + //! + //! The methods @[push_include_path()] and @[set_include_paths()] may not + //! behave as expected. At the moment the support for setting multiple + //! include paths seem to be lacking in @tt{libsass@}. So don't rely on + //! setting multiple include paths. + //!   //! @example   //! @code   //! Tools.Sass.Compiler compiler = Tools.Sass.Compiler(); -  + //! + //! // Allow for HTTP imports, disallowed by default. + //! compiler->http_import = Tools.Sass.HTTP_IMPORT_ANY; + //!   //! // 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
pike.git/module.pmod.in:36:    inherit Tools@module@.Api;    //! @endignore       //! If a Sass file is importing an external URI this flag determines if    //! thats allowed at all, or if the content type of the imported file has    //! to be text/scss or if anything goes. Default is @[HTTP_IMPORT_NONE].    //!    //! @seealso    //! @[HTTP_IMPORT_NONE], @[HTTP_IMPORT_GREEDY] and    //! @[HTTP_IMPORT_ANY]. -  public int(0..2) import_http = HTTP_IMPORT_NONE; +  public int(0..2) http_import = HTTP_IMPORT_NONE;       -  +  //! Should file access be tested right away when paths are set or should that +  //! be left to Sass to handle? The default value is @tt{true@}. +  public bool check_file_access = true; +  +     //! @ignore    protected void create()    {    ::__set_importer_callback(__resolve_import);    }    //! @endignore       //! @ignore    //! Resolve external imports in sass files.    protected string __resolve_import(string path)    {    Standards.URI uri;    -  +  // If it's not an URI we assume it's a local import and we let Sass handle +  // it. This could of course be a, by mistake, malformed URI, but then Sass +  // will eventually throw.    if (catch (uri = Standards.URI(path))) {    return UNDEFINED;    }    -  if (import_http == HTTP_IMPORT_NONE) { +  if (http_import == HTTP_IMPORT_NONE) {    error("Imports over HTTP not allowed!\n");    }       Protocols.HTTP.Query q = Protocols.HTTP.get_url(uri);       if (q->status != 200) {    error("Bad HTTP status (%d) for @import %q!\n",    q->status, (string) uri);    }       array(string) ct_parts = map(q->headers["content-type"]/";",    String.trim_all_whites);    -  if (import_http == HTTP_IMPORT_GREEDY) { +  if (http_import == HTTP_IMPORT_GREEDY) {    if (ct_parts[0] != "text/scss") {    error("Returned content type from import (%s) was %q. "    "Expected \"text/scss\"!\n",    uri, ct_parts[0]);    }    }       string(8bit) data = q->data();       if (sizeof(ct_parts) > 1) {
pike.git/module.pmod.in:93:    if (charset && charset[0] < 65) {    charset = charset[1..<1];    }    }       return data;    }    //! @endignore       +  //! @ignore +  //! Documented i the CMOD +  void set_include_path(string path) +  { +  if (check_file_access && !Stdio.exist(path)) { +  error("Include path %q does not exist or isn't accessible!\n", +  path); +  } +  +  ::set_include_path(path); +  } +  //! @endignore +     //! Set include paths    //!    //! @param paths    void set_include_paths(array(string) paths)    {    foreach (paths, string path) { -  +  if (check_file_access && !Stdio.exist(path)) { +  error("Include path %q does not exist or isn't accessible!\n", +  path); +  } +     push_include_path(path);    }    }          //! Compile the file @[input_file] and return the result    //!    //! @param input_file    //! The SCSS file to compile    //!
pike.git/module.pmod.in:121:    //! set to be generated    //!    //! @mapping    //! @member string "css"    //! The generated CSS    //! @member string "map"    //! The generated source mapping data    //! @endmapping    mapping(string:string) compile_file(string input_file)    { +  if (check_file_access && !Stdio.exist(input_file)) { +  error("Input file %q does not exist or isn't accessible!\n", +  input_file); +  } +     mapping(string:string) val = ::compile_file(input_file);    return val;    }       //! Compile the file @[input_file] and write the result to @[output_file].    //! If a source mapping file is set to be generated either via    //! @[set_options()] or @[set_source_map_file()] it will be written as per    //! the value set in the option.    //!    //! @param input_file    //! The SCSS file to compile    //! @param output_file    //! The name of the CSS file to save the result in.    variant void compile_file(string input_file, string output_file)    { -  +  if (check_file_access && !Stdio.exist(input_file)) { +  error("Input file %q does not exist or isn't accessible!\n", +  input_file); +  } +     mapping(string:string) val = ::compile_file(input_file);    Stdio.write_file(output_file, val->css);       if (val->map) {    string smap_path = ::get_source_map_file();    Stdio.write_file(smap_path, val->map);    }    }          //! Compile the string @[source]    //! -  +  //! @note +  //! If the @[source] contain @tt{@@import@} directives you have to +  //! explicitly set the include path via @[set_include_path()]. +  //!    //! @param source    //! The string to compile    string(8bit) compile_string(string(8bit) source)    {    string(8bit) out = ::compile_string(source);    return out;    }          //! Set options to the SASS compiler. @[opts]