pax_global_header00006660000000000000000000000064130360504450014512gustar00rootroot0000000000000052 comment=492616e3142f0c28a9974ce5939ffe1ffdddeea1 sassphp-0.5.10/000077500000000000000000000000001303605044500132565ustar00rootroot00000000000000sassphp-0.5.10/.gitignore000066400000000000000000000006311303605044500152460ustar00rootroot00000000000000*~ *.swp *.lo *.la .deps .libs Makefile Makefile.fragments Makefile.global Makefile.objects acinclude.m4 aclocal.m4 autom4te.cache build config.cache config.guess config.h config.h.in config.log config.nice config.status config.sub configure configure.in conftest conftest.c include install-sh libtool ltmain.sh missing mkinstalldirs modules scan_makefile_in.awk *.dsw *.plg *.opt *.ncb run-tests.php test.phpsassphp-0.5.10/.gitmodules000066400000000000000000000001341303605044500154310ustar00rootroot00000000000000[submodule "lib/libsass"] path = lib/libsass url = https://github.com/hcatlin/libsass.git sassphp-0.5.10/.travis.yml000066400000000000000000000035021303605044500153670ustar00rootroot00000000000000language: php php: - 5.4 - 5.5 - 5.6 - 7.0 - 7.1 - nightly allow_failures: - php: nightly addons: apt: packages: - php5-dev - gdb env: global: # Configure the .phpt tests to be Travis friendly - REPORT_EXIT_STATUS=1 - TEST_PHP_ARGS="-q -s output.txt -g XFAIL,FAIL,BORK,WARN,LEAK,SKIP -x --show-diff" # Add the pip installation folder to the PATH, until https://github.com/travis-ci/travis-ci/issues/3563 is fixed - PATH=$HOME/.local/bin:$PATH compiler: - gcc install: # What is the current file size max for core files? # It is usually 0, which means no core file will be dumped if there is a crash - ulimit -c before_install: - echo $LANG - echo $LC_ALL - composer require satooshi/php-coveralls --dev - git submodule init - git submodule update before_script: - travis_retry composer self-update - composer config discard-changes true - ulimit -c unlimited -S # enable core dumps script: - make clean - cd lib/libsass && make && cd ../.. - phpize - ./configure - make - echo "extension = sass.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini - export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${TRAVIS_BUILD_DIR}/modules" - make install - mkdir -p build/logs - phpunit --coverage-clover build/logs/clover.xml - make test || RESULT=$? - if [[ ${RESULT} == 0 ]]; then echo "\\o/ our test worked without problems"; else echo "ruhroh test returned an errorcode of $RESULT"; fi; - for i in $(find ./ -maxdepth 1 -name 'core*' -print); do gdb $(pwd)/test core* -ex "thread apply all bt" -ex "set pagination 0" -batch; done; - if [[ ${RESULT} != 0 ]]; then exit $RESULT ; fi; after_success: - travis_retry php vendor/bin/coveralls notifications: on_success: never on_failure: never os: - linux matrix: fast_finish: true sassphp-0.5.10/LICENSE000066400000000000000000000021211303605044500142570ustar00rootroot00000000000000Copyright (c) 2012 Jamie Rumbelow, pottions Copyright (c) 2013 Philip Hofstetter Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. sassphp-0.5.10/README.md000066400000000000000000000147541303605044500145500ustar00rootroot00000000000000# sassphp The `sass` extension for PHP gives you an object-oriented system of parsing [Sass](http://sass-lang.com/) from within your PHP applications. Under the hood it uses [libsass](https://github.com/hcatlin/libsass) to provide super speedy and compatible Sass parsing. ![Libsass 3.4.3](https://img.shields.io/badge/libsass-3.4.3-yellow.svg) [![Build Status](https://travis-ci.org/absalomedia/sassphp.svg)](https://travis-ci.org/absalomedia/sassphp) ## What's Sass? Sass is a CSS pre-processor language to add on exciting, new, awesome features to CSS. Sass was the first language of its kind and by far the most mature and up to date codebase. Sass was originally created by Hampton Catlin ([@hcatlin](http://twitter.com/hcatlin)). The extension and continuing evolution of the language has all been the result of years of work by Natalie Weizenbaum ([@nex3](http://twitter.com/nex3)) and Chris Eppstein ([@chriseppstein](http://twitter.com/chriseppstein)). For more information about Sass itself, please visit [http://sass-lang.com](http://sass-lang.com) ## Installation Currently, the only way to install the extension is manually: $ git clone git://github.com/absalomedia/sassphp Remember to grab your submodules: $ git submodule init $ git submodule update Also remember that libsass now uses submodules on its own, so update those too. ...and compile it! I've written a little PHP script to do all the stuff you need to do: $ php install.php Run the tests: $ make test Finally, you can install with `make`: $ make install And then add it to your _php.ini_: extension=sass.so ## Usage This extension has a very simple API: $sass = new Sass(); $css = $sass->compile($source); You can compile a file with `compileFile()`: $sass = new Sass(); $css = $sass->compileFile($source); You can set the include path for the library to use: $sass = new Sass(); $sass->setIncludePath('/tmp'); $css = $sass->compile($source); You can set the style of your SASS file to suit your needs: $sass = new Sass(); $sass->setStyle(Sass::STYLE_NESTED); $sass = new Sass(); $sass->setStyle(Sass::STYLE_EXPANDED); $sass = new Sass(); $sass->setStyle(Sass::STYLE_COMPACT); $sass = new Sass(); $sass->setStyle(Sass::STYLE_COMPRESSED); As the [Libsass](https://github.com/hcatlin/libsass) library has matured to get closer to 100% SASS coverage, so this extension has also matured: * SASS file compilation is an array when a source map file is specified. * The ability to define source comments * The ability to embed the source map into the CSS output * The ability to specify .SASS file input instead of .SCSS * The ability to set a source map path, required when generating a dedicated .map file * The ability to define a root directory for the source map itself * PHP 5.4 to PHP 7.1 (nightly) support The output of `compileFile()` is an array when creating source map files, allowing both compiled SASS file and .map file to be generated in the same function call. As there are multiple ways of generating source comments, there are now PHP level settings to control that output. To generate source comments for a file inline: $sass = new Sass(); $sass->setComments(true); $css = $sass->compileFile($source); Aliases also exist so you can also use: $css = $sass->compile_file($source); You can tell the compiler to use indented syntax (SASS syntax). By default it expects SCSS syntax: $sass = new Sass(); $sass->setIndent(true); //TRUE -> SASS, FALSE -> SCSS $css = $sass->compile($source); You can tell the compiler to embed the source map into the actual CSS file as well: $sass = new Sass(); $sass->setEmbed(true); $css = $sass->compile($source); You can set the source map file for the library to use: $sass = new Sass(); $sass->setMapPath('/random.output.css.map'); $css = $sass->compileFile($source); This needs to be done prior to getting the output of the map file. As it stands, both the output of the SASS file compile & the SASS source map file generation sequence are both strings. The first array item will always be the compiled SASS file: $css[0] The second array item will always be the source map output: $css[1] You can set the root of the generated source map file like so: $sass = new Sass(); $sass->setMapRoot('/some/dir'); $sass->setMapPath('/random.output.css.map'); $css = $sass->compileFile($source); If there's a problem, the extension will throw a `SassException`: $sass = new Sass(); try { $css = $sass->compile('dayrui3dui36di37'); } catch (SassException $e) { // $e->getMessage() - ERROR -- , line 1: invalid top-level expression $css = FALSE; } ## Variant builds These extensions also utilise the [Libsass](https://github.com/hcatlin/libsass) library & remain in varying states of completion: * Facebook [HHVM](https://github.com/absalomedia/sasshhvm) native (non Zend) extension - with Libsass 3.4.3 - tested up to HHVM 3.11.x * [Nginx](https://github.com/absalomedia/sass-nginx-module) module - with Libsass 3.4.3 ## Changelog | Release | Description | | --- | --- | | 0.5.10 | Elwood (Libsass 3.4.3) stable & Travis fix | | 0.5.9 | Rickshaw (Libsass 3.4.2) stable | | 0.5.8 | AI - KITT (Libsass 3.4.0) stable | | 0.5.7 | Hancock - Optimise loops & Travis. Simplify changelog documentation | | 0.5.6 | Green Giant - PHP5 & PHP7 stable build - All Travis builds passing | | 0.5.5 | Herbie (Libsass 3.3.6) stable | | 0.5.2 | Delorean (Libsass 3.3.3) stable & continuing PHP7 rewrite | | 0.5.1 | Eleanor (Libsass 3.3.2) stable | | 0.5.0 | Start of PHP 7 compatibility | | 0.4.9 | Too Fast To Furious (Libsass 3.3.1) stable | | 0.4.8 | Greased Lightning (Libsass 3.3.0) stable | | 0.4.7 | SCSS vs SASS detection - indents | | 0.4.6 | Travis experimental (unreleased) | | 0.4.5 | Holiday Patch (Libsass 3.2.5) stable | | 0.4.4 | Refactor correctly for LibSass 3.2.4 | | 0.4.2 | CamelCase compile sequence | | 0.4.1 | Addition of SOURCE_DEFAULT test & structure. Revise other tests | | 0.4.0 | Refactor file compliation. Basic tests for source comments. Expand documentation | | 0.3.9 | Addition of source map url paths to SASS file compilation | | 0.3.5 | Restructure of compile sequence (file only at this time) to account for source map output | | 0.3.0 | Addition of source comments - none, inline, file. Set default to none. | | 0.2.0 | Changed methods to be non-static. Allow setting include-path and image-path | | 0.1.0 | Initial release | sassphp-0.5.10/Sassphp.sln000066400000000000000000000023631303605044500154210ustar00rootroot00000000000000 Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.23107.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Sassphp", "Sassphp.vcxproj", "{DA0105A7-279B-4B5C-B8BC-39AABF5A2FBF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {DA0105A7-279B-4B5C-B8BC-39AABF5A2FBF}.Debug|x64.ActiveCfg = Debug|x64 {DA0105A7-279B-4B5C-B8BC-39AABF5A2FBF}.Debug|x64.Build.0 = Debug|x64 {DA0105A7-279B-4B5C-B8BC-39AABF5A2FBF}.Debug|x86.ActiveCfg = Debug|Win32 {DA0105A7-279B-4B5C-B8BC-39AABF5A2FBF}.Debug|x86.Build.0 = Debug|Win32 {DA0105A7-279B-4B5C-B8BC-39AABF5A2FBF}.Release|x64.ActiveCfg = Release|x64 {DA0105A7-279B-4B5C-B8BC-39AABF5A2FBF}.Release|x64.Build.0 = Release|x64 {DA0105A7-279B-4B5C-B8BC-39AABF5A2FBF}.Release|x86.ActiveCfg = Release|Win32 {DA0105A7-279B-4B5C-B8BC-39AABF5A2FBF}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal sassphp-0.5.10/Sassphp.vcxproj000066400000000000000000000322031303605044500163140ustar00rootroot00000000000000 Debug Win32 Release Win32 Debug x64 Release x64 {DA0105A7-279B-4B5C-B8BC-39AABF5A2FBF} Win32Proj DynamicLibrary true v140 DynamicLibrary false v140 Application true v140 Application false v140 true true WIN32;_DEBUG;_WINDOWS;_USRDLL;SASSPHP_EXPORTS;%(PreprocessorDefinitions) MultiThreadedDebugDLL Level3 ProgramDatabase Disabled MachineX86 true Windows WIN32;NDEBUG;_WINDOWS;_USRDLL;SASSPHP_EXPORTS;%(PreprocessorDefinitions) MultiThreadedDLL Level3 ProgramDatabase MachineX86 true Windows true true sassphp-0.5.10/Sassphp.vcxproj.filters000066400000000000000000000257451303605044500200000ustar00rootroot00000000000000 {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hh;hpp;hxx;hm;inl;inc;xsd {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files sassphp-0.5.10/appveyor.yml000066400000000000000000000016261303605044500156530ustar00rootroot00000000000000environment: PHP_VERSION: 5.6.21 configuration: Release version: '0.0.{build}' matrix: fast_finish: true install: - cd C:\projects\sassphp - git submodule init - git submodule update - cd C:\ - mkdir php-src - echo Preparing Windows build... - echo Downloading PHP source code [%PHP_VERSION%] - cd C:\php-src - appveyor DownloadFile http://windows.php.net/downloads/releases/php-5.6.21-src.zip -FileName php-src.zip - 7z x -y php-src.zip > nul - '"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64' build_script: - cd C:\php-src\php-5.6.21-src - buildconf.bat --add-modules-dir=C:\projects - configure --disable-all --enable-cli --enable-sass - nmake php_sass.dll test: OFF test_script: OFF deploy: OFF notifications: - on_build_success: false on_build_failure: false on_build_status_changed: false artifacts: - path: ext\Release_TS\php_sass.dllsassphp-0.5.10/config.m4000066400000000000000000000015321303605044500147660ustar00rootroot00000000000000PHP_ARG_ENABLE(sass, [whether to enable sass extension], [ --enable-sass Enable sass extension], yes, yes) if test "$PHP_SASS" != "no"; then PHP_ADD_INCLUDE(lib/libsass/include) PHP_ADD_LIBRARY_WITH_PATH(sass, lib/libexec, LIBSASS_SHARED_LIBADD) LDFLAGS="-lsass -L"`pwd`"/lib/libsass/lib/ -lstdc++" # manually extract sass version as the non-autotool'ed # sass_version.h that comes with libsass doesn't contain # the version sass_version=$(cd lib/libsass && ./version.sh) if test "x$sass_version" != "x" ; then # escape hell. This is what we need to pass to the # compiler: -DLIBSASS_VERSION="\"'3.3.3\"" CFLAGS="-DLIBSASS_VERSION=\"\\\"$sass_version\\\"\" $CFLAGS" CXXFLAGS="-DLIBSASS_VERSION=\"\\\"$sass_version\\\"\" $CXXFLAGS" fi PHP_NEW_EXTENSION(sass, src/sass.c src/utilities.c, $ext_shared) fi sassphp-0.5.10/config.w32000066400000000000000000000016061303605044500150630ustar00rootroot00000000000000// vim:ft=javascript ARG_ENABLE("sass", "whether to enable sass extension", "yes"); ADD_FLAG('CFLAGS', ' /wd4005 /wd4267 /wd4244 '); ADD_FLAG('CFLAGS_BD_ZEND', ' /wd4018 /wd4101 /wd4090 /wd4273 '); ADD_FLAG('CFLAGS_BD_MAIN', ' /wd4018 /wd4090 '); ADD_FLAG('CFLAGS_BD_MAIN_STREAMS', ' /wd4013 '); DEFINE('RC', '$(RC) /nologo /d _USING_V110_SDK71_'); ADD_FLAG('CFLAGS_BD_EXT_STANDARD', ' /wd4047 /wd4018 '); ADD_FLAG('CFLAGS_BD_SAPI_CLI', ' /wd4018 '); if (PHP_SASS == "yes") { CHECK_LIB("sass", ' '+ PROGRAM_FILES + '\\Apache Group\\Apache\\libexec', LIBSASS_SHARED_LIBADD); LDFLAGS="-lsass /libpath:/lib/libsass/lib/"; EXTENSION("sass", "src/sass.c src/utilities.c", PHP_EXTNAME_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); if ("x$sass_version" != "x") { CFLAGS="-DLIBSASS_VERSION=\"\\\"$sass_version\\\"\" $CFLAGS"; CXXFLAGS="-DLIBSASS_VERSION=\"\\\"$sass_version\\\"\" $CXXFLAGS"; } }sassphp-0.5.10/install.php000066400000000000000000000002041303605044500154310ustar00rootroot00000000000000 ./tests/ ./tests/ ./tests ./vendor/ sassphp-0.5.10/src/000077500000000000000000000000001303605044500140455ustar00rootroot00000000000000sassphp-0.5.10/src/php_sass.h000066400000000000000000000021301303605044500160320ustar00rootroot00000000000000/** * Sass * PHP bindings to libsass - fast, native Sass parsing in PHP! * * https://github.com/jamierumbelow/sassphp * Copyright (c)2012 Jamie Rumbelow */ #ifndef PHP_SASS_H #define PHP_SASS_H #ifdef HAVE_CONFIG_H #include "config.h" #endif #define SASS_VERSION "0.5.10" #define SASS_FLAVOR "Sassyphpras" #include #include #include #include #include zend_class_entry *sass_ce; zend_class_entry *sass_exception_ce; zend_class_entry *sass_get_exception_base(); PHP_METHOD(Sass, __construct); PHP_METHOD(Sass, compile); PHP_METHOD(Sass, compileFile); PHP_METHOD(Sass, getStyle); PHP_METHOD(Sass, setStyle); PHP_METHOD(Sass, getIncludePath); PHP_METHOD(Sass, setIncludePath); PHP_METHOD(Sass, getPrecision); PHP_METHOD(Sass, setPrecision); PHP_METHOD(Sass, getComments); PHP_METHOD(Sass, setComments); PHP_METHOD(Sass, getIndent); PHP_METHOD(Sass, setIndent); PHP_METHOD(Sass, getEmbed); PHP_METHOD(Sass, setEmbed); PHP_METHOD(Sass, getMapPath); PHP_METHOD(Sass, setMapPath); #endif sassphp-0.5.10/src/sass.c000066400000000000000000000517111303605044500151670ustar00rootroot00000000000000/** * Sass * PHP bindings to libsass - fast, native Sass parsing in PHP! * * https://github.com/jamierumbelow/sassphp * Copyright (c)2012 Jamie Rumbelow * * Fork updated and maintained by https://github.com/absalomedia */ #include #if ZEND_MODULE_API_NO > 20131226 #include . #endif #include "php_sass.h" #include "utilities.h" /* -------------------------------------------------------------- * Sass * ------------------------------------------------------------ */ zend_object_handlers sass_handlers; typedef struct sass_object { #if PHP_MAJOR_VERSION < 7 zend_object zo; #endif int style; char* include_paths; bool comments; bool indent; long precision; char* map_path; bool omit_map_url; bool map_embed; bool map_contents; char* map_root; #if PHP_MAJOR_VERSION >= 7 zend_object zo; #endif } sass_object; zend_class_entry *sass_ce; #if PHP_MAJOR_VERSION >= 7 static inline sass_object *sass_fetch_object(zend_object *obj) { return (sass_object *) ((char*) (obj) - XtOffsetOf(sass_object, zo)); } #define Z_SASS_P(zv) sass_fetch_object(Z_OBJ_P((zv))); static void sass_free_storage(zend_object *object TSRMLS_DC) { sass_object *obj; obj = sass_fetch_object(object); zend_object_std_dtor(object TSRMLS_DC); } #else void sass_free_storage(void *object TSRMLS_DC) { sass_object *obj = (sass_object *)object; if (obj->include_paths != NULL) efree(obj->include_paths); if (obj->map_path != NULL) efree(obj->map_path); if (obj->map_root != NULL) efree(obj->map_root); zend_hash_destroy(obj->zo.properties); FREE_HASHTABLE(obj->zo.properties); efree(obj); } #endif #if ZEND_MODULE_API_NO <= 20131226 zend_object_value sass_create_handler(zend_class_entry *type TSRMLS_DC) { zval *tmp; zend_object_value retval; sass_object *obj = (sass_object *)emalloc(sizeof(sass_object)); memset(obj, 0, sizeof(sass_object)); obj->zo.ce = type; ALLOC_HASHTABLE(obj->zo.properties); zend_hash_init(obj->zo.properties, 0, NULL, ZVAL_PTR_DTOR, 0); #if PHP_VERSION_ID > 50399 object_properties_init(&(obj->zo), type); #endif retval.handle = zend_objects_store_put(obj, NULL, sass_free_storage, NULL TSRMLS_CC); retval.handlers = &sass_handlers; return retval; } #endif #if ZEND_MODULE_API_NO > 20131226 zend_object * sass_create_handler(zend_class_entry *type TSRMLS_DC) { struct sass_object *obj = ecalloc(1, sizeof(struct sass_object) + zend_object_properties_size(type)); zend_object_std_init(&obj->zo, type TSRMLS_CC); object_properties_init(&obj->zo, type TSRMLS_CC); obj->zo.handlers = &sass_handlers; return &obj->zo; } #endif PHP_METHOD(Sass, __construct) { zval *this = getThis(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "", NULL) == FAILURE) { RETURN_NULL(); } #if ZEND_MODULE_API_NO > 20131226 sass_object *obj = Z_SASS_P(this); #endif #if ZEND_MODULE_API_NO <= 20131226 sass_object *obj = (sass_object *)zend_object_store_get_object(this TSRMLS_CC); #endif obj->style = SASS_STYLE_NESTED; obj->include_paths = NULL; obj->map_path = NULL; obj->map_root = NULL; obj->comments = false; obj->indent = false; obj->map_embed = false; obj->map_contents = false; obj->omit_map_url = true; obj->precision = 5; } void set_options(sass_object *this, struct Sass_Context *ctx) { struct Sass_Options* opts = sass_context_get_options(ctx); sass_option_set_precision(opts, this->precision); sass_option_set_output_style(opts, this->style); sass_option_set_is_indented_syntax_src(opts, this->indent); if (this->include_paths != NULL) { sass_option_set_include_path(opts, this->include_paths); } sass_option_set_source_comments(opts, this->comments); if (this->comments) { sass_option_set_omit_source_map_url(opts, false); } sass_option_set_source_map_embed(opts, this->map_embed); sass_option_set_source_map_contents(opts, this->map_contents); if (this->map_path != NULL) { sass_option_set_source_map_file(opts, this->map_path); sass_option_set_omit_source_map_url(opts, false); sass_option_set_source_map_contents(opts, true); } if (this->map_root != NULL) { sass_option_set_source_map_root(opts, this->map_root); } } /** * $sass->parse(string $source, [ ]); * * Parse a string of Sass; a basic input -> output affair. */ PHP_METHOD(Sass, compile) { #if ZEND_MODULE_API_NO > 20131226 sass_object *this = Z_SASS_P(getThis()); #endif #if ZEND_MODULE_API_NO <= 20131226 sass_object *this = (sass_object *)zend_object_store_get_object(getThis() TSRMLS_CC); #endif // Define our parameters as local variables char *source; #if ZEND_MODULE_API_NO <= 20131226 int source_len; #endif #if ZEND_MODULE_API_NO > 20131226 size_t source_len; #endif // Use zend_parse_parameters() to grab our source from the function call if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &source, &source_len) == FAILURE){ RETURN_FALSE; } // Create a new sass_context struct Sass_Data_Context* data_context = sass_make_data_context(strdup(source)); struct Sass_Context* ctx = sass_data_context_get_context(data_context); set_options(this, ctx); int status = sass_compile_data_context(data_context); // Check the context for any errors... if (status != 0) { zend_throw_exception(sass_exception_ce, sass_context_get_error_message(ctx), 0 TSRMLS_CC); } else { #if ZEND_MODULE_API_NO <= 20131226 RETVAL_STRING(sass_context_get_output_string(ctx), 1); #endif #if ZEND_MODULE_API_NO > 20131226 RETVAL_STRING(sass_context_get_output_string(ctx)); #endif } sass_delete_data_context(data_context); } /** * $sass->parse_file(string $file_name); * * Parse a whole file FULL of Sass and return the CSS output */ PHP_METHOD(Sass, compileFile) { array_init(return_value); #if ZEND_MODULE_API_NO > 20131226 sass_object *this = Z_SASS_P(getThis()); #endif #if ZEND_MODULE_API_NO <= 20131226 sass_object *this = (sass_object *)zend_object_store_get_object(getThis() TSRMLS_CC); #endif // We need a file name and a length char *file; #if ZEND_MODULE_API_NO <= 20131226 int file_len; #endif #if ZEND_MODULE_API_NO > 20131226 size_t file_len; #endif // Grab the file name from the function if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file, &file_len) == FAILURE) { RETURN_FALSE; } // First, do a little checking of our own. Does the file exist? if( access( file, F_OK ) == -1 ) { zend_throw_exception_ex(sass_exception_ce, 0 TSRMLS_CC, "File %s could not be found", file); RETURN_FALSE; } struct Sass_File_Context* file_ctx = sass_make_file_context(file); struct Sass_Context* ctx = sass_file_context_get_context(file_ctx); set_options(this, ctx); int status = sass_compile_file_context(file_ctx); // Check the context for any errors... if (status != 0) { zend_throw_exception(sass_exception_ce, sass_context_get_error_message(ctx), 0 TSRMLS_CC); } else { #if ZEND_MODULE_API_NO <= 20131226 if (this->map_path != NULL ) { // Send it over to PHP. add_next_index_string(return_value, sass_context_get_output_string(ctx), 1); } else { RETVAL_STRING(sass_context_get_output_string(ctx), 1); } // Do we have source maps to go? if (this->map_path != NULL) { // Send it over to PHP. add_next_index_string(return_value, sass_context_get_source_map_string(ctx), 1); } #endif #if ZEND_MODULE_API_NO > 20131226 if (this->map_path != NULL ) { // Send it over to PHP. add_next_index_string(return_value, sass_context_get_output_string(ctx)); } else { RETVAL_STRING(sass_context_get_output_string(ctx)); } // Do we have source maps to go? if (this->map_path != NULL) { // Send it over to PHP. add_next_index_string(return_value, sass_context_get_source_map_string(ctx)); } #endif } sass_delete_file_context(file_ctx); } PHP_METHOD(Sass, getStyle) { zval *this = getThis(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "", NULL) == FAILURE) { RETURN_FALSE; } #if ZEND_MODULE_API_NO > 20131226 sass_object *obj = Z_SASS_P(this); #endif #if ZEND_MODULE_API_NO <= 20131226 sass_object *obj = (sass_object *)zend_object_store_get_object(this TSRMLS_CC); #endif RETURN_LONG(obj->style); } PHP_METHOD(Sass, setStyle) { zval *this = getThis(); long new_style; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &new_style) == FAILURE) { RETURN_FALSE; } #if ZEND_MODULE_API_NO > 20131226 sass_object *obj = Z_SASS_P(this); #endif #if ZEND_MODULE_API_NO <= 20131226 sass_object *obj = (sass_object *)zend_object_store_get_object(this TSRMLS_CC); #endif obj->style = new_style; RETURN_NULL(); } PHP_METHOD(Sass, getIncludePath) { zval *this = getThis(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "", NULL) == FAILURE) { RETURN_FALSE; } #if ZEND_MODULE_API_NO > 20131226 sass_object *obj = Z_SASS_P(this); #endif #if ZEND_MODULE_API_NO <= 20131226 sass_object *obj = (sass_object *)zend_object_store_get_object(this TSRMLS_CC); #endif #if ZEND_MODULE_API_NO <= 20131226 if (obj->include_paths == NULL) RETURN_STRING("", 1); RETURN_STRING(obj->include_paths, 1); #endif #if ZEND_MODULE_API_NO > 20131226 if (obj->include_paths == NULL) RETURN_STRING(""); RETURN_STRING(obj->include_paths); #endif } PHP_METHOD(Sass, setIncludePath) { zval *this = getThis(); char *path; #if ZEND_MODULE_API_NO <= 20131226 int path_len; #endif #if ZEND_MODULE_API_NO > 20131226 size_t path_len; #endif if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &path, &path_len) == FAILURE) RETURN_FALSE; #if ZEND_MODULE_API_NO > 20131226 sass_object *obj = Z_SASS_P(this); #endif #if ZEND_MODULE_API_NO <= 20131226 sass_object *obj = (sass_object *)zend_object_store_get_object(this TSRMLS_CC); #endif if (obj->include_paths != NULL) efree(obj->include_paths); obj->include_paths = estrndup(path, path_len); RETURN_NULL(); } PHP_METHOD(Sass, getMapPath) { zval *this = getThis(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "", NULL) == FAILURE) { RETURN_FALSE; } #if ZEND_MODULE_API_NO > 20131226 sass_object *obj = Z_SASS_P(this); #endif #if ZEND_MODULE_API_NO <= 20131226 sass_object *obj = (sass_object *)zend_object_store_get_object(this TSRMLS_CC); #endif #if ZEND_MODULE_API_NO <= 20131226 if (obj->map_path == NULL) RETURN_STRING("", 1); RETURN_STRING(obj->map_path, 1); #endif #if ZEND_MODULE_API_NO > 20131226 if (obj->map_path == NULL) RETURN_STRING(""); RETURN_STRING(obj->map_path); #endif } PHP_METHOD(Sass, setMapPath) { zval *this = getThis(); char *path; #if ZEND_MODULE_API_NO <= 20131226 int path_len; #endif #if ZEND_MODULE_API_NO > 20131226 size_t path_len; #endif if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &path, &path_len) == FAILURE) RETURN_FALSE; #if ZEND_MODULE_API_NO > 20131226 sass_object *obj = Z_SASS_P(this); #endif #if ZEND_MODULE_API_NO <= 20131226 sass_object *obj = (sass_object *)zend_object_store_get_object(this TSRMLS_CC); #endif if (obj->map_path != NULL) efree(obj->map_path); obj->map_path = estrndup(path, path_len); RETURN_NULL(); } PHP_METHOD(Sass, getPrecision) { zval *this = getThis(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "", NULL) == FAILURE) { RETURN_FALSE; } #if ZEND_MODULE_API_NO > 20131226 sass_object *obj = Z_SASS_P(this); #endif #if ZEND_MODULE_API_NO <= 20131226 sass_object *obj = (sass_object *)zend_object_store_get_object(this TSRMLS_CC); #endif RETURN_LONG(obj->precision); } PHP_METHOD(Sass, setPrecision) { zval *this = getThis(); long new_precision; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &new_precision) == FAILURE) { RETURN_FALSE; } #if ZEND_MODULE_API_NO > 20131226 sass_object *obj = Z_SASS_P(this); #endif #if ZEND_MODULE_API_NO <= 20131226 sass_object *obj = (sass_object *)zend_object_store_get_object(this TSRMLS_CC); #endif obj->precision = new_precision; RETURN_NULL(); } PHP_METHOD(Sass, getEmbed) { zval *this = getThis(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "", NULL) == FAILURE) { RETURN_FALSE; } #if ZEND_MODULE_API_NO > 20131226 sass_object *obj = Z_SASS_P(this); #endif #if ZEND_MODULE_API_NO <= 20131226 sass_object *obj = (sass_object *)zend_object_store_get_object(this TSRMLS_CC); #endif RETURN_LONG(obj->map_embed); } PHP_METHOD(Sass, setEmbed) { zval *this = getThis(); bool new_map_embed; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &new_map_embed) == FAILURE) { RETURN_FALSE; } #if ZEND_MODULE_API_NO > 20131226 sass_object *obj = Z_SASS_P(this); #endif #if ZEND_MODULE_API_NO <= 20131226 sass_object *obj = (sass_object *)zend_object_store_get_object(this TSRMLS_CC); #endif obj->map_embed = new_map_embed; RETURN_NULL(); } PHP_METHOD(Sass, getComments) { zval *this = getThis(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "", NULL) == FAILURE) { RETURN_FALSE; } #if ZEND_MODULE_API_NO > 20131226 sass_object *obj = Z_SASS_P(this); #endif #if ZEND_MODULE_API_NO <= 20131226 sass_object *obj = (sass_object *)zend_object_store_get_object(this TSRMLS_CC); #endif RETURN_LONG(obj->comments); } PHP_METHOD(Sass, setComments) { zval *this = getThis(); bool new_comments; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &new_comments) == FAILURE) { RETURN_FALSE; } #if ZEND_MODULE_API_NO > 20131226 sass_object *obj = Z_SASS_P(this); #endif #if ZEND_MODULE_API_NO <= 20131226 sass_object *obj = (sass_object *)zend_object_store_get_object(this TSRMLS_CC); #endif obj->comments = new_comments; RETURN_NULL(); } PHP_METHOD(Sass, getIndent) { zval *this = getThis(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "", NULL) == FAILURE) { RETURN_FALSE; } #if ZEND_MODULE_API_NO > 20131226 sass_object *obj = Z_SASS_P(this); #endif #if ZEND_MODULE_API_NO <= 20131226 sass_object *obj = (sass_object *)zend_object_store_get_object(this TSRMLS_CC); #endif RETURN_LONG(obj->indent); } PHP_METHOD(Sass, setIndent) { zval *this = getThis(); bool new_indent; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &new_indent) == FAILURE) { RETURN_FALSE; } #if ZEND_MODULE_API_NO > 20131226 sass_object *obj = Z_SASS_P(this); #endif #if ZEND_MODULE_API_NO <= 20131226 sass_object *obj = (sass_object *)zend_object_store_get_object(this TSRMLS_CC); #endif obj->indent = new_indent; RETURN_NULL(); } PHP_METHOD(Sass, getLibraryVersion) { if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "", NULL) == FAILURE) { RETURN_FALSE; } #if ZEND_MODULE_API_NO <= 20131226 RETURN_STRING(libsass_version(), 1); #endif #if ZEND_MODULE_API_NO > 20131226 RETURN_STRING(libsass_version()); #endif } /* -------------------------------------------------------------- * EXCEPTION HANDLING * ------------------------------------------------------------ */ zend_class_entry *sass_get_exception_base(TSRMLS_D) { return zend_exception_get_default(TSRMLS_C); } /* -------------------------------------------------------------- * PHP EXTENSION INFRASTRUCTURE * ------------------------------------------------------------ */ ZEND_BEGIN_ARG_INFO(arginfo_sass_void, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_sass_compile, 0, 0, 1) ZEND_ARG_INFO(0, sass_string) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_sass_compileFile, 0, 0, 1) ZEND_ARG_INFO(0, filename) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_sass_setStyle, 0, 0, 1) ZEND_ARG_INFO(0, style) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_sass_setIncludePath, 0, 0, 1) ZEND_ARG_INFO(0, include_path) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_sass_setPrecision, 0, 0, 1) ZEND_ARG_INFO(0, precision) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_sass_setComments, 0, 0, 1) ZEND_ARG_INFO(0, comments) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_sass_setIndent, 0, 0, 1) ZEND_ARG_INFO(0, indent) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_sass_setEmbed, 0, 0, 1) ZEND_ARG_INFO(0, map_embed) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_sass_setMapPath, 0, 0, 1) ZEND_ARG_INFO(0, map_path) ZEND_END_ARG_INFO() zend_function_entry sass_methods[] = { PHP_ME(Sass, __construct, arginfo_sass_void, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) PHP_ME(Sass, compile, arginfo_sass_compile, ZEND_ACC_PUBLIC) PHP_ME(Sass, compileFile, arginfo_sass_compileFile, ZEND_ACC_PUBLIC) PHP_ME(Sass, getStyle, arginfo_sass_void, ZEND_ACC_PUBLIC) PHP_ME(Sass, setStyle, arginfo_sass_setStyle, ZEND_ACC_PUBLIC) PHP_ME(Sass, getIncludePath, arginfo_sass_void, ZEND_ACC_PUBLIC) PHP_ME(Sass, setIncludePath, arginfo_sass_setIncludePath, ZEND_ACC_PUBLIC) PHP_ME(Sass, getPrecision, arginfo_sass_void, ZEND_ACC_PUBLIC) PHP_ME(Sass, setPrecision, arginfo_sass_setPrecision, ZEND_ACC_PUBLIC) PHP_ME(Sass, getComments, arginfo_sass_void, ZEND_ACC_PUBLIC) PHP_ME(Sass, setComments, arginfo_sass_setComments, ZEND_ACC_PUBLIC) PHP_ME(Sass, getIndent, arginfo_sass_void, ZEND_ACC_PUBLIC) PHP_ME(Sass, setIndent, arginfo_sass_setIndent, ZEND_ACC_PUBLIC) PHP_ME(Sass, getEmbed, arginfo_sass_void, ZEND_ACC_PUBLIC) PHP_ME(Sass, setEmbed, arginfo_sass_setEmbed, ZEND_ACC_PUBLIC) PHP_ME(Sass, getMapPath, arginfo_sass_void, ZEND_ACC_PUBLIC) PHP_ME(Sass, setMapPath, arginfo_sass_setMapPath, ZEND_ACC_PUBLIC) PHP_ME(Sass, getLibraryVersion, arginfo_sass_void, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_MALIAS(Sass, compile_file, compileFile, NULL, ZEND_ACC_PUBLIC) {NULL, NULL, NULL} }; static PHP_MINIT_FUNCTION(sass) { zend_class_entry ce; zend_class_entry exception_ce; INIT_CLASS_ENTRY(ce, "Sass", sass_methods); sass_ce = zend_register_internal_class(&ce TSRMLS_CC); sass_ce->create_object = sass_create_handler; memcpy(&sass_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); #if ZEND_MODULE_API_NO > 20131226 sass_handlers.offset = XtOffsetOf(struct sass_object, zo); sass_handlers.free_obj = sass_free_storage; #endif sass_handlers.clone_obj = NULL; INIT_CLASS_ENTRY(exception_ce, "SassException", NULL); #if ZEND_MODULE_API_NO > 20131226 sass_exception_ce = zend_register_internal_class_ex(&exception_ce, sass_get_exception_base(TSRMLS_C)); #endif #if ZEND_MODULE_API_NO <= 20131226 sass_exception_ce = zend_register_internal_class_ex(&exception_ce, sass_get_exception_base(TSRMLS_C), NULL TSRMLS_CC); #endif #define REGISTER_SASS_CLASS_CONST_LONG(name, value) zend_declare_class_constant_long(sass_ce, ZEND_STRS( #name ) - 1, value TSRMLS_CC) REGISTER_SASS_CLASS_CONST_LONG(STYLE_NESTED, SASS_STYLE_NESTED); REGISTER_SASS_CLASS_CONST_LONG(STYLE_EXPANDED, SASS_STYLE_EXPANDED); REGISTER_SASS_CLASS_CONST_LONG(STYLE_COMPACT, SASS_STYLE_COMPACT); REGISTER_SASS_CLASS_CONST_LONG(STYLE_COMPRESSED, SASS_STYLE_COMPRESSED); REGISTER_STRING_CONSTANT("SASS_FLAVOR", SASS_FLAVOR, CONST_CS | CONST_PERSISTENT); return SUCCESS; } static PHP_MINFO_FUNCTION(sass) { php_info_print_table_start(); php_info_print_table_row(2, "sass support", "enabled"); php_info_print_table_row(2, "version", SASS_VERSION); php_info_print_table_row(2, "flavor", SASS_FLAVOR); php_info_print_table_row(2, "libsass version", libsass_version()); php_info_print_table_end(); } static zend_module_entry sass_module_entry = { STANDARD_MODULE_HEADER, "sass", NULL, PHP_MINIT(sass), NULL, NULL, NULL, PHP_MINFO(sass), SASS_VERSION, STANDARD_MODULE_PROPERTIES }; #ifdef COMPILE_DL_SASS ZEND_GET_MODULE(sass) #endif sassphp-0.5.10/src/utilities.c000066400000000000000000000007731303605044500162330ustar00rootroot00000000000000/** * Sass * PHP bindings to libsass - fast, native Sass parsing in PHP! * * https://github.com/jamierumbelow/sassphp * Copyright (c)2012 Jamie Rumbelow */ #include #include #include "utilities.h" /** * A C implementation of PHP's trim() */ char *trim(char *str) { char *end; while(isspace(*str)) str++; if(*str == 0) { return str; } end = str + strlen(str) - 1; while(end > str && isspace(*end)) end--; *(end+1) = 0; return str; }sassphp-0.5.10/src/utilities.h000066400000000000000000000004231303605044500162300ustar00rootroot00000000000000/** * Sass * PHP bindings to libsass - fast, native Sass parsing in PHP! * * https://github.com/jamierumbelow/sassphp * Copyright (c)2012 Jamie Rumbelow * * Fork updated and maintained by https://github.com/pilif */ char *trim(char *str); sassphp-0.5.10/tests/000077500000000000000000000000001303605044500144205ustar00rootroot00000000000000sassphp-0.5.10/tests/arginfo_present.phpt000066400000000000000000000007151303605044500205050ustar00rootroot00000000000000--TEST-- Making sure ARG_INFO is present --SKIPIF-- --FILE-- getMethod("setIncludePath"); $params = $m->getParameters(); echo $params[0]."\n"; $m = $c->getMethod("setStyle"); $params = $m->getParameters(); echo $params[0]."\n"; ?> --EXPECT-- Parameter #0 [ $include_path ] Parameter #0 [ $style ] sassphp-0.5.10/tests/available.phpt000066400000000000000000000002771303605044500172430ustar00rootroot00000000000000--TEST-- Check for sass presence --SKIPIF-- --FILE-- --EXPECT-- sass extension is availablesassphp-0.5.10/tests/check_bundled_libsass_version.phpt000066400000000000000000000003021303605044500233470ustar00rootroot00000000000000--TEST-- check bundled libsass version --SKIPIF-- --FILE-- --EXPECT-- 0 sassphp-0.5.10/tests/class_exists.phpt000066400000000000000000000003071303605044500200210ustar00rootroot00000000000000--TEST-- Test Sass is a class --SKIPIF-- --FILE-- --EXPECT-- Sass class existssassphp-0.5.10/tests/class_instantiatable.phpt000066400000000000000000000003041303605044500215010ustar00rootroot00000000000000--TEST-- Test Sass is instantiatable --SKIPIF-- --FILE-- --EXPECT-- Sasssassphp-0.5.10/tests/file_comments.phpt000066400000000000000000000007151303605044500201440ustar00rootroot00000000000000--TEST-- compiles correct Sass file and provides source comments --SKIPIF-- --FILE-- setComments(true); $css = $sass->compileFile(__DIR__.'/support/test.scss'); echo $css; ?> --EXPECTF-- @import url(../blahblah/blah.blah); /* line 3, %s/support/test.scss */ div { blah: "hello 4 world px bloo blah"; } /* line 9, %s/support/test.scss */ div { blah: "foo iphone"; } sassphp-0.5.10/tests/file_embed.phpt000066400000000000000000000014021303605044500173650ustar00rootroot00000000000000--TEST-- compiles correct Sass file and provides source embedding --SKIPIF-- --FILE-- setEmbed(true); $css = $sass->compileFile(__DIR__.'/support/test.scss'); echo $css; ?> --EXPECT-- @import url(../blahblah/blah.blah); div { blah: "hello 4 world px bloo blah"; } div { blah: "foo iphone"; } /*# sourceMappingURL=data:application/json;base64,ewoJInZlcnNpb24iOiAzLAoJImZpbGUiOiAidGVzdHMvc3VwcG9ydC90ZXN0LmNzcyIsCgkic291cmNlcyI6IFsKCQkidGVzdHMvc3VwcG9ydC90ZXN0LnNjc3MiCgldLAoJIm5hbWVzIjogW10sCgkibWFwcGluZ3MiOiAiQUFBQSxPQUFPLENBQUMsMEJBQUk7QUFFWixBQUFBLEdBQUcsQ0FBQztFQUNGLElBQUksRUFBRSw0QkFBaUQsR0FDeEQ7O0FBSUQsQUFBQSxHQUFHLENBQUM7RUFDQSxJQUFJLEVBQUUsWUFBYSxHQUN0QiIKfQ== */ sassphp-0.5.10/tests/file_indent.phpt000066400000000000000000000005201303605044500175720ustar00rootroot00000000000000--TEST-- compiles SASS file in comparison to SCSS based SASS file --SKIPIF-- --FILE-- setIndent(true); $css = $sass->compileFile(__DIR__.'/support/source_type.sass'); echo $css; ?> --EXPECT-- body { background: red; border: 1px solid green; }sassphp-0.5.10/tests/handles_comments.phpt000066400000000000000000000006171303605044500206440ustar00rootroot00000000000000--TEST-- correctly handles setting and getting comments --SKIPIF-- --FILE-- getComments(); // test SASS_SOURCE_NONE $sass->setComments(false); echo $sass->getComments(); // test SASS_SOURCE_DEFAULT $sass->setComments(true); echo $sass->getComments(); ?> --EXPECT-- 001 sassphp-0.5.10/tests/handles_embed.phpt000066400000000000000000000006101303605044500200640ustar00rootroot00000000000000--TEST-- correctly handles setting and getting source embedding --SKIPIF-- --FILE-- getEmbed(); // test SASS_SOURCE_NONE $sass->setEmbed(false); echo $sass->getEmbed(); // test SASS_SOURCE_DEFAULT $sass->setEmbed(true); echo $sass->getEmbed(); ?> --EXPECT-- 001 sassphp-0.5.10/tests/handles_include_path.phpt000066400000000000000000000005721303605044500214560ustar00rootroot00000000000000--TEST-- correctly handles includePath --SKIPIF-- --FILE-- setIncludePath(__DIR__.'/support'); $css = $sass->compile(' @import "foo"; '); echo $css; echo $sass->compileFile(__DIR__.'/support/import.scss'); ?> --EXPECT-- h2 { color: green; } h2 { color: green; } h1 { color: red; } sassphp-0.5.10/tests/handles_indent.phpt000066400000000000000000000005721303605044500203000ustar00rootroot00000000000000--TEST-- correctly handles setting and getting SCSS / SASS file indents --SKIPIF-- --FILE-- getIndent(); // test SCSS $sass->setIndent(false); echo $sass->getIndent(); // test SASS $sass->setIndent(true); echo $sass->getIndent(); ?> --EXPECT-- 001 sassphp-0.5.10/tests/handles_map.phpt000066400000000000000000000014221303605044500175670ustar00rootroot00000000000000--TEST-- correctly handles setting and getting source map formats --SKIPIF-- --FILE-- setComments(true); $sass->setMapPath(__DIR__.'/support/test.css.map'); $css = $sass->compileFile(__DIR__.'/support/test.scss'); echo $css[1]; ?> --EXPECT-- { "version": 3, "file": "test.css", "sources": [ "test.scss" ], "sourcesContent": [ "@import url(../blahblah/blah.blah);\n\ndiv {\n blah: \"hello #{2+2} world #{unit(23px)} #{'bloo'} blah\";\n}\n\n$foo: iphone;\n\ndiv {\n blah: \"foo #{$foo}\"\n}\n" ], "names": [], "mappings": "AAAA,OAAO,CAAC,0BAAI;;AAEZ,AAAA,GAAG,CAAC;EACF,IAAI,EAAE,4BAAiD,GACxD;;;AAID,AAAA,GAAG,CAAC;EACA,IAAI,EAAE,YAAa,GACtB" } sassphp-0.5.10/tests/handles_precision.phpt000066400000000000000000000013611303605044500210070ustar00rootroot00000000000000--TEST-- correctly handles setting and getting precision --SKIPIF-- --FILE-- getPrecision() . "\n"; // compile with above precision echo $sass->compile($scss); // set to "large" number $sass->setPrecision(10); echo $sass->getPrecision() . "\n"; // compile with above precision echo $sass->compile($scss); // set to "small" number $sass->setPrecision(1); echo $sass->getPrecision() . "\n"; // compile with above precision echo $sass->compile($scss); ?> --EXPECT-- 5 body { width: 33.33333%; } 10 body { width: 33.3333333333%; } 1 body { width: 33.3%; } sassphp-0.5.10/tests/handles_style.phpt000066400000000000000000000011311303605044500201470ustar00rootroot00000000000000--TEST-- correctly handles setting and getting style --SKIPIF-- --FILE-- getStyle(); // test SASS_OUTPUT_NESTED $sass->setStyle(Sass::STYLE_NESTED); echo $sass->getStyle(); // test SASS_OUTPUT_EXPANDED $sass->setStyle(Sass::STYLE_EXPANDED); echo $sass->getStyle(); // test SASS_OUTPUT_COMPACT $sass->setStyle(Sass::STYLE_COMPACT); echo $sass->getStyle(); // test SASS_OUTPUT_COMPRESSED $sass->setStyle(Sass::STYLE_COMPRESSED); echo $sass->getStyle(); ?> --EXPECT-- 00123sassphp-0.5.10/tests/old_compile_file_alias_exists.phpt000066400000000000000000000005201303605044500233470ustar00rootroot00000000000000--TEST-- old compile_file() alias exists --SKIPIF-- --FILE-- compile_file('tests/support/test.scss'); echo $css; ?> --EXPECT-- @import url(../blahblah/blah.blah); div { blah: "hello 4 world px bloo blah"; } div { blah: "foo iphone"; } sassphp-0.5.10/tests/parse_file_parses_file.phpt000066400000000000000000000005231303605044500220020ustar00rootroot00000000000000--TEST-- compileFile() compiles correct file --SKIPIF-- --FILE-- compileFile('tests/support/test.scss'); echo $css; ?> --EXPECT-- @import url(../blahblah/blah.blah); div { blah: "hello 4 world px bloo blah"; } div { blah: "foo iphone"; } sassphp-0.5.10/tests/parse_parses_correct_sass.phpt000066400000000000000000000007431303605044500225620ustar00rootroot00000000000000--TEST-- parse() parses correct Sass --SKIPIF-- --FILE-- compile(' table.hl { margin: 2em 0; td.ln { text-align: right; } } li { font: { family: serif; weight: bold; size: 1.2em; } } '); echo $css; ?> --EXPECT-- table.hl { margin: 2em 0; } table.hl td.ln { text-align: right; } li { font-family: serif; font-weight: bold; font-size: 1.2em; } sassphp-0.5.10/tests/support/000077500000000000000000000000001303605044500161345ustar00rootroot00000000000000sassphp-0.5.10/tests/support/foo.scss000066400000000000000000000000311303605044500176060ustar00rootroot00000000000000h2 { color: green; } sassphp-0.5.10/tests/support/import.scss000066400000000000000000000000461303605044500203430ustar00rootroot00000000000000@import 'foo'; h1 { color: red; } sassphp-0.5.10/tests/support/source_type.sass000066400000000000000000000001521303605044500213660ustar00rootroot00000000000000$color: red =my-border($color) border: 1px solid $color body background: $color +my-border(green) sassphp-0.5.10/tests/support/test.scss000066400000000000000000000002301303605044500200030ustar00rootroot00000000000000@import url(../blahblah/blah.blah); div { blah: "hello #{2+2} world #{unit(23px)} #{'bloo'} blah"; } $foo: iphone; div { blah: "foo #{$foo}" } sassphp-0.5.10/tests/throw_exception.phpt000066400000000000000000000004621303605044500205400ustar00rootroot00000000000000--TEST-- If there's an error while parsing, throw a SassException --SKIPIF-- --FILE-- compile('askdgauwydv7iq2dq'); } catch (SassException $e) { echo 'Exception caught'; } ?> --EXPECT-- Exception caught