This repository has been archived by the owner on Jul 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docs.php.html
2466 lines (2360 loc) · 84.8 KB
/
docs.php.html
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"><script type="text/javascript">
//<![CDATA[
try{if (!window.CloudFlare) {var CloudFlare=[{verbose:0,p:0,byc:0,owlid:"cf",bag2:1,mirage2:0,oracle:0,paths:{cloudflare:"/cdn-cgi/nexp/dok3v=1613a3a185/"},atok:"67a9f60e17e767e5bb23b289b87db25a",petok:"bb9ef6293c11f4eb0afcae980f6a65c7cdf20c28-1448330135-1800",zone:"turbinecss.org",rocket:"0",apps:{"clky":{"sid":"66513652","uid":"0"}},sha2test:0}];!function(a,b){a=document.createElement("script"),b=document.getElementsByTagName("script")[0],a.async=!0,a.src="//ajax.cloudflare.com/cdn-cgi/nexp/dok3v=6f4db11806/cloudflare.min.js",b.parentNode.insertBefore(a,b)}()}}catch(e){};
//]]>
</script>
<script type="text/javascript">window.NREUM||(NREUM={}),__nr_require=function(e,n,t){function r(t){if(!n[t]){var o=n[t]={exports:{}};e[t][0].call(o.exports,function(n){var o=e[t][1][n];return r(o?o:n)},o,o.exports)}return n[t].exports}if("function"==typeof __nr_require)return __nr_require;for(var o=0;o<t.length;o++)r(t[o]);return r}({QJf3ax:[function(e,n){function t(e){function n(n,t,a){e&&e(n,t,a),a||(a={});for(var u=c(n),f=u.length,s=i(a,o,r),p=0;f>p;p++)u[p].apply(s,t);return s}function a(e,n){f[e]=c(e).concat(n)}function c(e){return f[e]||[]}function u(){return t(n)}var f={};return{on:a,emit:n,create:u,listeners:c,_events:f}}function r(){return{}}var o="nr@context",i=e("gos");n.exports=t()},{gos:"7eSDFh"}],ee:[function(e,n){n.exports=e("QJf3ax")},{}],3:[function(e,n){function t(e){return function(){r(e,[(new Date).getTime()].concat(i(arguments)))}}var r=e("handle"),o=e(1),i=e(2);"undefined"==typeof window.newrelic&&(newrelic=window.NREUM);var a=["setPageViewName","addPageAction","setCustomAttribute","finished","addToTrace","inlineHit","noticeError"];o(a,function(e,n){window.NREUM[n]=t("api-"+n)}),n.exports=window.NREUM},{1:12,2:13,handle:"D5DuLP"}],gos:[function(e,n){n.exports=e("7eSDFh")},{}],"7eSDFh":[function(e,n){function t(e,n,t){if(r.call(e,n))return e[n];var o=t();if(Object.defineProperty&&Object.keys)try{return Object.defineProperty(e,n,{value:o,writable:!0,enumerable:!1}),o}catch(i){}return e[n]=o,o}var r=Object.prototype.hasOwnProperty;n.exports=t},{}],D5DuLP:[function(e,n){function t(e,n,t){return r.listeners(e).length?r.emit(e,n,t):void(r.q&&(r.q[e]||(r.q[e]=[]),r.q[e].push(n)))}var r=e("ee").create();n.exports=t,t.ee=r,r.q={}},{ee:"QJf3ax"}],handle:[function(e,n){n.exports=e("D5DuLP")},{}],XL7HBI:[function(e,n){function t(e){var n=typeof e;return!e||"object"!==n&&"function"!==n?-1:e===window?0:i(e,o,function(){return r++})}var r=1,o="nr@id",i=e("gos");n.exports=t},{gos:"7eSDFh"}],id:[function(e,n){n.exports=e("XL7HBI")},{}],G9z0Bl:[function(e,n){function t(){var e=d.info=NREUM.info,n=f.getElementsByTagName("script")[0];if(e&&e.licenseKey&&e.applicationID&&n){c(p,function(n,t){n in e||(e[n]=t)});var t="https"===s.split(":")[0]||e.sslForHttp;d.proto=t?"https://":"http://",a("mark",["onload",i()]);var r=f.createElement("script");r.src=d.proto+e.agent,n.parentNode.insertBefore(r,n)}}function r(){"complete"===f.readyState&&o()}function o(){a("mark",["domContent",i()])}function i(){return(new Date).getTime()}var a=e("handle"),c=e(1),u=window,f=u.document;e(2);var s=(""+location).split("?")[0],p={beacon:"bam.nr-data.net",errorBeacon:"bam.nr-data.net",agent:"js-agent.newrelic.com/nr-686.min.js"},d=n.exports={offset:i(),origin:s,features:{}};f.addEventListener?(f.addEventListener("DOMContentLoaded",o,!1),u.addEventListener("load",t,!1)):(f.attachEvent("onreadystatechange",r),u.attachEvent("onload",t)),a("mark",["firstbyte",i()])},{1:12,2:3,handle:"D5DuLP"}],loader:[function(e,n){n.exports=e("G9z0Bl")},{}],12:[function(e,n){function t(e,n){var t=[],o="",i=0;for(o in e)r.call(e,o)&&(t[i]=n(o,e[o]),i+=1);return t}var r=Object.prototype.hasOwnProperty;n.exports=t},{}],13:[function(e,n){function t(e,n,t){n||(n=0),"undefined"==typeof t&&(t=e?e.length:0);for(var r=-1,o=t-n||0,i=Array(0>o?0:o);++r<o;)i[r]=e[n+r];return i}n.exports=t},{}]},{},["G9z0Bl"]);</script>
<title>TurbineCSS</title>
<link href="turbine/css.php%3Ffiles=turbine.cssp.css" rel="stylesheet">
</head>
<body>
<div id="top"></div>
<header>
<div class="wrapper">
<h1>
<a href="index.php.html"><span>Turbine</span></a>
</h1>
<nav>
<ul id="navi">
<li class="first"><a href="index.php.html"><span>Home</span></a></li>
<li><a href="download.php.html"><span>Download</span></a></li>
<li><a href="docs.php.html"><span>Docs</span></a></li>
<li><a href="support.php.html"><span>Support</span></a></li>
<li><a href="shell.php.html"><span>Sandbox</span></a></li>
<li><a href="converter.php.html"><span>Converter</span></a></li>
<li><a href="http://github.com/TurbineCSS/Turbine"><span>Development</span></a></li>
</ul>
</nav>
</div>
</header>
<div id="wrapper">
<div class="clear"></div>
<div id="docs">
<div id="toc">
<ul>
<li>↓ <a href="docs.php.html#intro">Introduction</a>
<ul>
<li><a href="docs.php.html#intro-goalsandfeatures">Goals and Features</a></li>
</ul>
</li>
<li>↓ <a href="docs.php.html#usage">Usage</a>
<ul>
<li><a href="docs.php.html#usage-setup">Installation and setup</a></li>
<li><a href="docs.php.html#usage-editor">Editor setup</a></li>
<li><a href="docs.php.html#usage-syntax">Basic syntax</a></li>
<li><a href="docs.php.html#usage-configuration">Configuration</a></li>
<li><a href="docs.php.html#usage-advanced">Advanced syntax</a></li>
<li><a href="docs.php.html#usage-paths">Paths</a></li>
<li><a href="docs.php.html#usage-constantsaliases">Constants and aliases</a></li>
<li><a href="docs.php.html#usage-inheritancetemplating">Inheritance and prototyping</a></li>
</ul>
</li>
<li>↓ <a href="docs.php.html#plugins">Core Plugins</a>
<ul>
<li><a href="docs.php.html#plugins-fontface">@font-face</a></li>
<li><a href="docs.php.html#plugins-backgroundgradient">Background gradient</a></li>
<li><a href="docs.php.html#plugins-borderradius">Border radius</a></li>
<li><a href="docs.php.html#plugins-boxshadow">Box shadow</a></li>
<li><a href="docs.php.html#plugins-boxsizing">Box sizing</a></li>
<li><a href="docs.php.html#plugins-sniffer">Browser and platform sniffer</a></li>
<li><a href="docs.php.html#plugins-bugfix">Browser bugfixes</a></li>
<li><a href="docs.php.html#plugins-colormodels">Colormodels</a></li>
<li><a href="docs.php.html#plugins-datauri">Data-URIs</a></li>
<li><a href="docs.php.html#plugins-html5">HTML5</a></li>
<li><a href="docs.php.html#plugins-inlineblock">Inline block</a></li>
<li><a href="docs.php.html#plugins-load">Load</a></li>
<li><a href="docs.php.html#plugins-minifier">Minifier</a></li>
<li><a href="docs.php.html#plugins-opacity">Opacity</a></li>
<li><a href="docs.php.html#plugins-quote">Quote style</a></li>
<li><a href="docs.php.html#plugins-reset">Reset stylesheet</a></li>
<li><a href="docs.php.html#plugins-transforms">Transforms</a></li>
<li><a href="docs.php.html#plugins-meta">Meta plugins</a></li>
</ul>
</li>
<li>↓ <a href="docs.php.html#dev">Development</a>
<ul>
<li><a href="docs.php.html#dev-contribute">Contribute</a></li>
<li><a href="docs.php.html#dev-plugins">Plugin development</a></li>
<li><a href="docs.php.html#dev-styleguide">Style guide</a></li>
</ul>
</li>
<li>↓ <a href="docs.php.html#tools">Tools</a>
<ul>
<li><a href="docs.php.html#tools-converter">Converter</a></li>
<li><a href="docs.php.html#tools-shell">Shell</a></li>
</ul>
</li>
<li>↓ <a href="docs.php.html#faq">FAQ</a>
<ul>
<li><a href="docs.php.html#faq-why">Why use Turbine?</a></li>
<li><a href="docs.php.html#faq-tradeoffs">What are the tradeoffs?</a></li>
<li><a href="docs.php.html#faq-static">Non-server environments?</a></li>
<li><a href="docs.php.html#faq-performance">What about performance?</a></li>
<li><a href="docs.php.html#faq-projects">Ready for real projects?</a></li>
<li><a href="docs.php.html#faq-cache">Disable the Cache?</a></li>
<li><a href="docs.php.html#faq-cssp">What's CSSP?</a></li>
<li><a href="docs.php.html#faq-advice">Any general advice?</a></li>
</ul>
</li>
</ul>
</div>
<h2 id="intro">Introduction</h2><div>
<p class="warning">
This document describes <em>Turbine 1.0</em>. You can find documentation for Version 1.1 (which is currently in beta state) in the <a href="docs-11.php.html">new docs</a>.
</p>
<p>
Turbine is a PHP-powered tool that introduces a new way for writing CSS. It's syntax and features are designed to
decrease css development time and web developer headache. Turbine takes this …
</p>
<pre class="cssp">
// Welcome to Turbine!
@media screen
#foo, #bar
color:#FF0000
margin-left, margin-right: 4px
div.alpha, div.beta
font-weight:bold
border-radius:4px</pre>
… and turns it into …
<pre class="css">@media screen {
#foo, #bar {
color: #FF0000;
margin-left: 4px;
margin-right: 4px;
}
#foo div.alpha, #foo div.beta, #bar div.alpha, #bar div.beta {
font-weight: bold;
border-radius: 4px;
}
}</pre>
<p>
…or, if you like fast-loading websites, directly into this (which is automatically cached, gezipped and served with the correct expires headers):
</p>
<pre class="css">@media screen{#foo,#bar{color:#F00;margin-left:4px;margin-right:4px}#foo div.alpha,#foo div.beta,#bar div.alpha,#bar div.beta{font-weight:bold;-moz-border-radius:4px;-webkit-border-radius:4px;-khtml-border-radius:4px;border-radius:4px}}</pre>
<p>
Turbine can save you a lot of typing and time <em>and</em> allow you to focus on a website's design and functionality instead of
css's limitations, page performance or your least favourite browser's latest bugs. Think jQuery for CSS. Being fully extensible, you
can customize Turbine to your liking.
</p>
<h3 id="intro-goalsandfeatures">Goals and Features</h3><div>
<p>
Turbine's basic features include:
</p>
<ul>
<li>Minmal syntax – the less you have to type, the more you get done</li>
<li>Packing, gzipping and automatic minification of multiple css files</li>
<li>Constants (also known as "css variables") and selector aliases</li>
<li>Oop-like inheritance, extension and templating features</li>
<li>Nested css selectors</li>
<li>Built-in device-, browser- and os sniffing</li>
<li>Fully exensible through a very simple plugin system</li>
</ul>
<p>
While Turbine's basic features may save you some keystrokes, it's plugins automate and simplify some of the more tedious and complicated
aspects of writing css. See the plugins section for details.
</p>
</div>
</div>
<h2 id="usage">Usage</h2><div>
<h3 id="usage-setup">Installation and setup</h3><div>
<h4>Installation</h4>
<p>
Simply download the latest public release from <a href="http://github.com/SirPepe/Turbine">Github</a> and unpack it to a directory on your
web server. There are no requirements beside PHP 5.2.
</p>
<h4>Global configuration</h4>
<p>
Turbine has two sets of configuration options - one on a per-file-basis and one on a global level. These global configuration options
are set in the file <code>config.php</code>. The following settings are availiable:
</p>
<table>
<thead>
<tr>
<th>Option</th>
<th>Effect</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>debug_level</code></td>
<td>Disable all error messages (<code>0</code>), enable web developer debugging messages (<code>1</code>) or enable all error messages
(<code>2</code>). Setting this to anything but 0 also disables Turbine's server-side cache.</td>
<td><code>1</code></td>
</tr>
<tr>
<td><code>css_base_dir</code></td>
<td>Sets the base directory for the css and cssp files</td>
<td></td>
</tr>
<tr>
<td><code>minify_css</code></td>
<td>Leave css files unchanged by Turbine (<code>false</code>) or minify them (<code>true</code>)</td>
<td><code>true</code></td>
</tr>
</tbody>
</table>
<p class="warning">
<em>Security notice</em>: As of version 1.0.5 Turbine can only access files in the <code>css_base_dir</code> to prevent directory traversal.
</p>
<h4>Adding Turbine files to HTML documents</h4>
<p>
Turbine files are simple text files with the extension <abbr title="CSS Preprocessor"><code>.cssp</code></abbr>.
To use Turbine, embed <code>css.php</code> in your HTML like a normal css file and add the <code>files</code> argument containing
a list of Turbine files separated by semicolons.
</p>
<pre><link
rel="stylesheet"
href="path/to/turbine/css.php?files=file1.cssp;file2.cssp"
/></pre>
<p>
The base path for the files can be changed in the file <code>config.php</code> (<code>css_base_dir</code>).
You can also include regular css files, which will be output unchanged (or minified, if the <code>minify_css</code>
configuration option is set to <code>true</code>).
</p>
<p>
The files as processed in sequence and <strong>don't</strong> influence each other in any way. For example,
<a href="docs.php.html#usage-constantsaliases">constants</a> defined in <code>file1</code> won't apply to code in <code>file2</code>. If
you want share code between files, use the <a href="docs.php.html#plugins-load">loader plugin</a>.
</p>
<h3 id="usage-editor">Setting up your editor</h3>
<p>
There's basic Turbine support for Dreamweaver, UltraEdit and GtkSourceView.
</p>
<h4>Dreamweaver</h4>
<p>
You can find an extension for <strong>Dreamweaver</strong> in <code>resources/editors/dreamweaver</code>. This extension adds
.cssp-files to Dreamweaver's list of supported filetypes, puts in place some code highlighting and autocompletion (code hinting)
for Turbine files. To install the extension, just double click <code>turbine.mxp</code>, or open the Extension Manager and select
File → Install Extension…, browse for <code>turbine.mxp</code> and select it.
</p>
<p>
<img src="img/dreamweaver.png" alt="Dreamweaver code view" width="650" height="559">
</p>
<h4>UltraEdit</h4>
<p>
Follow <a href="http://www.ultraedit.com/support/tutorials_power_tips/ultraedit/add_a_wordfile.html">this guide</a> on how to add
the Turbine wordfile <code>resources/editors/ultraedit/turbine.uew</code> to <strong>UltraEdit</strong>. Use the tags listed in
<code>resources/editors/ultraedit/turbine.txt</code> to complete your tag list.
</p>
<p>
<img src="img/ultraedit.png" alt="UntraEdit source view" width="550" height="456">
</p>
<h4>GtkSourceView</h4>
<p>
The language file for <strong>GtkSourceView</strong> adds syntax highlighting to editors like Gedit and Anjuta. Simply copy the
file <code>turbine.lang</code> from <code>resources/editors/gtksourceview-2.0/language-specs</code> to either
<code>~/.local/share/editors/gtksourceview-2.0/language-specs</code> or
<code>/usr/local/share/editors/gtksourceview-2.0/language-specs</code>.
</p>
<p>
<img src="img/gtksourceview.png" alt="GtkSourceView highlighting in action" width="498" height="500">
</p>
<h4>TextMate</h4>
<p>
The <code>Turbine.tmbundle</code> adds syntax highlighting with a small property and plugin documentation for <strong>TextMate</strong>. Simply copy the
file <code>Turbine.tmbundle</code> from <code>resources/editors/textmate</code> to
<code>~/Library/Application Support/TextMate/Bundles</code>. Now select Bundles → Bundle Editor → Reload Bundles from within TextMate.
</p>
<p>
<img src="img/textmate.png" alt="Turbine code in TextMate" width="649" height="491">
</p>
<h3 id="usage-syntax">Basic syntax</h3><div>
<p>
The one important thing about Turbine's syntax is that it is all about <strong>lines</strong>. The context of any statements
in the code depends of the context of the statement's line.
</p>
<h4>Selectors and rules</h4>
<p>
Turbine's syntax works a bit like <a href="docs.php.html#">Python</a> – <strong>the level of indentation</strong> instead of curly braces
decides the context of a given line. A simple rule looks like this:
</p>
<pre class="cssp">#foo div > p // Selector
color:red // Property and value
font-weight:bold // Property and value</pre>
<p>
The way Turbine determines if a given line is a selector or a property-value-pair is the indentation level of the <em>following</em>
line:
</p>
<pre class="cssp">#foo div > p // Next line is indented = this is a selector
color:red
font-weight:bold
span // Next line is indented = this is a selector
color:blue</pre>
<p>
This behavior allows nested selectors, which can be quite powerful (see <a class="smoothscroll" href="docs.php.html#usage-nested">nested selectors</a>).
You can use any number or combination of spaces and tabs for indentation, but be careful to keep your indentation constistent in the whole
file.
</p>
<p>
Semicolons at the end of values are not required, but you can use them to put multiple declarations in one line:
</p>
<pre class="cssp">#foo div > p
color:red; font-weight:bold
span
color:blue; font-style:italic</pre>
<h4>Comments</h4>
<p>
There a two kinds of comments available: single line comments that start with <code>//</code> …
</p>
<pre class="cssp">// Hello world</pre>
<p>
… and block comments that start with a line containing nothing but <code>--</code> and end with the same:
</p>
<pre class="cssp">--
Hello world
This is a block comment
--</pre>
<h4>@media rules</h4>
<p>
<code>@media</code>-rules in Turbine a simple switches. Each <code>@media</code> line ends the previous <code>@media</code> block
and opens a new one.
<pre class="cssp">@media screen // Open screen block
#foo
background:red
@media print // Close screen block, open print block
#foo
background:green
@media projection // Close print block, open projection block
#foo
background:blue
@media screen // Close projection block, open screen block
#bar
font.weight:bold</pre>
<p>
<code>@media</code> block of the same type will be merged, so the resulting css looks like the following:
</p>
<pre class="css">@media screen {
#foo {
background: red;
}
#bar {
font.weight: bold;
}
}
@media print {
#foo {
background: green;
}
}
@media projection {
#foo {
background: blue;
}
}
</pre>
<p>
If you need to end an @media block without opening a new one, you can do so using <code>@media none</code>.
</p>
<pre class="cssp">@media screen
#foo
color:red
@media none
#bar
color:green</pre>
<p>
Result:
</p>
<pre class="css">#bar {
color: green;
}
@media screen {
#foo {
color: red;
}
}</pre>
<h4 id="usage-syntax-prefixes">Prefixes</h4>
<p>
There a a few reserved prefixes for properties, values and selectors:
</p>
<table>
<thead>
<tr>
<th>Prefix</th>
<th>Context</th>
<th>Effect</th>
</tr>
</thead>
<tbody>
<tr>
<th rowspan="2">$</th>
<td>Selector</td>
<td>Selector alias, will be replaced by the selector defined in <code>@aliases</code> (see <a class="smoothscroll" href="docs.php.html#usage-constantsaliases">Constants and aliases</a>)</td>
</tr>
<tr>
<td>Value</td>
<td>Constant, will be replaced by the value defined in <code>@constants</code> (see <a class="smoothscroll" href="docs.php.html#usage-constantsaliases">Constants and aliases</a>)</td>
</tr>
<tr>
<th>$_</th>
<td>Value</td>
<td>Special constant (<code>$_SCRIPTPATH</code>, <code>$_FILEPATH</code>, see <a class="smoothscroll" href="docs.php.html#usage-constantsaliases">Constants and aliases</a>)</td>
</tr>
<tr>
<th>?</th>
<td>Selector</td>
<td>Template - whole element will be removed before output but properties can be inherited from it (see <a class="smoothscroll" href="docs.php.html#usage-inheritancetemplating-templating">Templating</a>)</td>
</tr>
<tr>
<th>&</th>
<td>Value</td>
<td>Expression (currently not used by Turbine or any plugin)</td>
</tr>
</tbody>
</table>
</div>
<h3 id="usage-configuration">Configuration</h3><div>
<p>
The configuration options of Turbine can be set in the stylesheets themselves &ndash a <code>@turbine</code> block (called
<strong>configuration block</strong>) allows for options to be set like properties and values in normal CSS code. There are
at the moment two things that can be controlled there: compression and plugins.
</p>
<h4>Compression</h4>
<p>
Turbine can output CSS code in a minified form.
</p>
<pre class="cssp">@turbine
compress:1
#foo
color:red
background:blue</pre>
<p>
Becomes
</p>
<pre class="css">#foo{color:red;background:blue}</pre>
<p>
That's a good thing to have since everybody likes smaller downloads and the CSS code generates tends to be more verbose than
handwritten CSS anyway. To enable compression simply add <code>compress:1;</code> to your configuration block.
</p>
<h4>Plugins</h4>
<p>
To active a plugin, simply add it's name to the <code>plugins</code> property (the order doesn't matter):
</p>
<pre class="cssp">@turbine
plugins:resetstyle, datauri, borderradius</pre>
<p>
Turbine has a set of <a class="smoothscroll" href="docs.php.html#plugins">core plugins</a> that greatly enhance the functionality of Turbine. If
you know a bit of PHP you can <a class="smoothscroll" href="docs.php.html#dev-plugins">easily build your own plugins</a>.
</p>
</div>
<h3 id="usage-advanced">Advanced syntax features</h3><div>
<h4>Expanding properties</h4>
<p>
if you want to use multiple properties with the same value inside a selector, you can take advantage of expanding properties. This
allows you to use properties as a comma-separated list …
</p>
<pre class="cssp">#foo
position:absolute
top, left:4px</pre>
<p>
which Turbine expands into multiple css rules:
</p>
<pre class="css">#foo {
position: absolute;
top: 4px;
left: 4px;
}</pre>
</div>
<h4>Nested selectors</h4>
<p>
Turbine implements nested css selectors using a simple principle: whenever the <em>next</em> line is indented, to current line
is used as a selector and combined with it's parent selectors.
</p>
<pre class="cssp">#foo div > p
color:red
font-weight:bold
a:link, a:visited
text-decoration:underline
a:hover, a:active
text-decoration:none
a:focus
outline:1px dotted #CCC</pre>
<p>
The nested code above compiles to the following css:
</p>
<pre class="css">#foo div > p {
color: red;
font-weight: bold;
}
#foo div > p a:link, #foo div > p a:visited {
text-decoration: underline;
}
#foo div > p a:hover, #foo div > p a:active {
text-decoration: none;
}
#foo div > p a:focus {
outline: 1px dotted #CCC;
}</pre>
<p>
Without nested selectors you would have to have typed a lot more <code>#foo div > p</code>. Nested selectors <em>can</em> become a
bit confusing if you overuse them, but with a bit of moderation they can save quite a bit of typing. Consider this example:
</p>
<pre class="cssp">#header, #footer
ul, ol, p
a:link, a:visited
text-decoration:underline
a:active, a:hover
text-decoration:none</pre>
<p>
Result:
</p>
<pre class="css">#header ul a:link, #header ul a:visited,
#header ol a:link, #header ol a:visited,
#header p a:link, #header p a:visited,
#footer ul a:link, #footer ul a:visited,
#footer ol a:link, #footer ol a:visited,
#footer p a:link, #footer p a:visited {
text-decoration: underline;
}
#header ul a:active, #header ul a:hover,
#header ol a:active, #header ol a:hover,
#header p a:active, #header p a:hover,
#footer ul a:active, #footer ul a:hover,
#footer ol a:active, #footer ol a:hover,
#footer p a:active, #footer p a:hover {
text-decoration: none;
}</pre>
<h4>Multi-line selectors</h4>
<p>
A selector can span multiple lines if each line except the last one ends with a comma:
</p>
<pre class="cssp">#header,
#footer,
#foobar
color:red</pre>
<p>
To avoid confusion it is recommended to use <a class="smoothscroll" href="http://turbinecss.org/usage-constantsaliases">aliases</a> for complex selectors
instead.
</p>
<h4>CSS injection</h4>
<p>
In case you need to insert css without Turbine messing with it, you can use the <code>@css</code> prefix. Any lines that begin with
<code>@css</code> will appear in the output completely unchanged (except for the <code>@css</code> prefix which is removed).
</p>
<pre class="cssp">@css @-moz-document url-prefix(http://), url-prefix(https://), url-prefix(ftp://){
#foo
color:red
@css }</pre>
<p>
Result:
</p>
<pre class="css">@-moz-document url-prefix(http://), url-prefix(https://), url-prefix(ftp://){
#foo {
color: red;
}
}</pre>
<p>
If you have to use css hacks, this is the way to go.
</p>
</div>
<h3 id="usage-paths">Paths</h3><div>
<p>
If you want to use images or embed fonts, please note that <strong>all paths are relative to css.php</strong>! You can define constants or use the
special constants <code>$_SCRIPTPATH</code> and <code>$_FILEPATH</code> to work with this. See below for a detailed explaination of constants.
</p>
</div>
<h3 id="usage-constantsaliases">Constants and aliases</h3><div>
<h4>Constants</h4>
<p>
Constants (also known as "css variables") allow you to define your own easy-to-remember shortcuts for complicated hex colors
or long font stacks. They can be used for any css property and are <strong>case-sensitive</strong>.
</p>
<pre class="cssp">@constants
myRed:#C02222
imagePath:/assets/images
#foo
color:$myRed
background:url($imagePath/foo.png) top left no-repeat</pre>
<pre class="css">#foo {
color: #C02222;
background: url(/assets/images/foo.png) top left no-repeat;
}</pre>
<h4>Special constants</h4>
<p>
The constants defined in in an <code>@turbine</code> block only apply to the current .cssp file. There are two special constants
that apply globally and that are always made availiable by Turbine:
</p>
<ol>
<li><code>$_SCRIPTPATH</code>: The path to <code>css.php</code></li>
<li><code>$_FILEPATH</code>: The path to the current .cssp file</li>
</ol>
<h4>Aliases</h4>
<p>
Aliases are constants applied to selectors insted of values. Don't want to remember the complicated <code>#wrapper #header > div ul</code>?
You don't have to:
</p>
<pre class="cssp">@aliases
mainNavigation: #wrapper #header > div ul
$mainNavigation
list-style:none</pre>
<p>
The <code>@aliases</code> block defines <code>mainNavigation</code> as an alias of <code>#wrapper #header > div ul</code>, which
results us to the following css code:
</p>
<pre class="css">#wrapper #header > div ul {
list-style: none
}
</pre>
<p>
Aliases, like constants, are <strong>case-sensitive</strong>.
</p>
<h4>Scope</h4>
<p>
All <code>.cssp</code> are processed completly independent from each other. Inside the files, constants and aliases apply only to
the <code>@media</code>-block they are defined in. The exception is the set of constents defined outside of any block –
they apply to the whole file.
</p>
<p>
<img src="img/scope.png">
</p>
<p>
Example:
</p>
<pre class="cssp">@constants
mycolor:#F00 // Defined outside of any @media block = applies _globally_
@media screen
@constants
myothercolor:#00F // Defined in @media block = applies _only_ in the screen block
#foo
color:$mycolor
background:$myothercolor
@media print
#foo
color:$mycolor
background:$myothercolor // Won't work as "myothercolor" is only defined for the "screen" block, but not for "print"</pre>
<p>
Result:
</p>
<pre class="css">@media screen {
#foo {
color: #F00;
background: #00F;
}
}
@media print {
#foo {
color: #F00;
background: $myothercolor;
}
}</pre>
</div>
<h3 id="usage-inheritancetemplating">Inheritance and Prototyping</h3><div>
<p>
Turbine's inheritance, prototyping and copying features allow you to pass around chunks of properties and values between elements in
your code. Note that <code>@font-face</code> and <code>@import</code> elements can copy and interit properties from other elements,
but they cannot be copied or inherited from.
</p>
<h4>Copying values from other elements</h4>
<p>
To simply copy a value from a property in another selector, you can use the <code>copy(selector property)</code> syntax:
</p>
<pre class="cssp">#foo
color:#F00
#bar
color:copy(#foo color)</pre>
<p>
Result:
</p>
<pre class="css">#foo {
color: #F00
}
#bar {
color: #F00
}</pre>
<h4>Copying from other properties</h4>
<p>
The copied and copying properties don't have to be the same:
</p>
<pre class="cssp">#foo
background:#F00
#bar
color:copy(#foo background)</pre>
<p>
Result:
</p>
<pre class="css">#foo {
color: #F00
}
#bar {
background: #F00
}</pre>
<h4>Copying with aliases</h4>
<p>
Copying works with aliases too. If you want to copy the <code>color</code> value from $foo to #bar, you can simple use
<code>copy($foo color)</code>:
</p>
<pre class="cssp">@aliases
foo: #header > div.foobar
$foo
color:blue
#bar
background:copy($foo color)</pre>
<p>
Result:
</p>
<pre class="css">#header > div.foobar {
color: blue;
}
#bar {
background: blue;
}</pre>
<h4>Extending other elements</h4>
<p>
Turbine's <code>extends</code> let elements inherit complete sets of properties from other elements, which are merged with the
element's own properties:
</p>
<pre class="cssp">#parent
color:red
font-weight:bold
div.child
extends:#parent
margin:4px</pre>
<p>
Result:
</p>
<pre class="css">#parent {
color: red;
font-weight: bold;
}
div.child {
margin: 4px;
color: red;
font-weight: bold;
}</pre>
<p>
If a property is already defined in a element <code>extends</code> will <strong>not</strong> overwrite it:
</p>
<pre class="cssp">#parent
color:red
font-weight:bold
div.child
extends:#parent
font-weight:normal</pre>
<p>
Result:
</p>
<pre class="css">#parent {
color: red;
font-weight: bold;
}
div.child {
font-weight: normal;
color: red;
}</pre>
<p>
For inheritance from multiple sources, the parent elements <strong>must</strong> be quoted because of the comma character (which
otherwise might be part of a selector as well as a list sepperator):
</p>
<pre class="cssp">#parent1
color:red
#parent2
font-weight:bold
div.child
extends:"#parent1", "#parent2"</pre>
<p>
Result:
</p>
<pre class="css">#parent1 {
color: red;
}
#parent2 {
font-weight: bold;
}
div.child {
color: red;
font-weight: bold;
}
</pre>
<h3 id="usage-inheritancetemplating-prototyping">Prototyping</h3>
<h4>Using prototypes</h4>
<p>
The <code>?</code> prefix allows you to define elements that will be removed before output but from which properties can be inherited
or copied from (see <a class="smoothscroll" href="docs.php.html#usage-syntax-prefixes">prefixes</a>). These elements can be used to declare complete
building blocks for your real css elements:
</p>
<pre class="cssp">// Prototypes
?box
margin, padding:4px
?blackBox
background:#000
?whiteBox
background:#FFF
?roundedBox
border-radius:8px
// "Real" elements
div.whiteSqare
extends:"?box", "?whiteBox"
div.blackRound
extends:"?box", "?blackBox", "?roundedBox"</pre>
<p>
Result:
</p>
<pre class="css">div.whiteSqare {
margin: 4px;
padding: 4px;
background: #FFF;
}
div.blackRound {
margin: 4px;
padding: 4px;
background: #000;
border-radius: 8px;
}</pre>
<h4 id="usage-inheritancetemplating-prototyping-recycling">Recycling prototypes</h4>
<p>
The <a href="docs.php.html#plugins-load" class="smoothscroll">loader plugin</a> allows you (among other things) to build a library of prototypes,
store them in an external file and include them when you need them. The code for the black and white boxes above could then be shortend
to the following:
</p>
<pre class="cssp">@load url(myBoxTemplates.cssp)
div.whiteSqare
extends:"?box", "?whiteBox"
div.blackRound
extends:"?box", "?blackBox", "?roundedBox"</pre>
<p>
An additional bonus of building external libraries is that you can re-use them in all of your coming projects.
</p>
</div>
</div>
<h2 id="plugins">Core plugins</h2><div>
<h3 id="plugins-fontface">Simple @font-face</h3><div>
<p class="abstract">
Generates @font-face declarations from a simplified syntax.
</p>
<p>
<a href="http://paulirish.com/2009/bulletproof-font-face-implementation-syntax/">Bulletproof @font-face syntax</a> is a syntax
for embedding web fonts in a manner that works for all browsers and takes care of numerous browser quirks. Its only downside is that
it's rather complicated:
</p>
<pre class="css">@font-face {
font-family: 'Graublau Web';
src: url('GraublauWeb.eot');
src: local('Graublau Web Regular'), local('Graublau Web'),
url("GraublauWeb.woff") format("woff"),
url("GraublauWeb.otf") format("opentype"),
url("GraublauWeb.svg#grablau") format("svg");
}</pre>
<p>
The @font-face syntax plugin generates <strong>browser-specific @font-face declarations</strong> from a very simplified syntax.
</p>
<h4>Usage</h4>
<ol>
<li>Add <code>fontface</code> to <code>@turbine</code> plugin list</li>
<li>Put all different font-files into one directory and give them the same basename, e.g. "<code>SaginaMedium</code>":
<ul>
<li>SaginawMedium.eot</li>
<li>SaginawMedium.woff</li>
<li>SaginawMedium.otf</li>
<li>SaginawMedium.ttf</li>
<li>SaginawMedium.svg</li>
</ul>
</li>
<li>Build a special <code>@font-face</code>-rule with a single <code>src</code>-property pointing not to a real
file but to the common basename, e.g. "<code>src:url('fonts/SaginawMedium')</code>"</li>
<li>The plugin will look after any known fontfile format by appending the suffixes
<code>.eot, .woff, .otf, .ttf</code> and <code>.svg</code>.
<ul>
<li>For IE <= 8 it will serve the .eot-file if there is one named <code>fonts/SaginawMedium.eot</code>.</li>
<li>For the other browser it will serve as many of the other flavors as available.<br/>
A truetype-file will only be served when there is no opentype-file available.</li>
</ul>
</ol>
<h4>Example</h4>
<pre class="cssp">@turbine
plugins:fontface
@font-face
font-family:'SaginawMedium'
src:url('fonts/SaginawMedium')
font-weight:bold
font-style:italic</pre>
<p>
Result for IE <= 8:
</p>
<pre class="css">@font-face {
font-family: 'SaginawMedium';
src: url("fonts/SaginawMedium.eot");
font-weight: bold;
font-style: italic;
}</pre>
<p>
Result for all other browsers:
</p>
<pre class="css">@font-face {
font-family: 'SaginawMedium';
src: url("fonts/SaginawMedium.woff") format("woff"),
url("fonts/SaginawMedium.ttf") format("truetype"),
url("fonts/SaginawMedium.svg#SaginawMedium") format("svg");
font-weight: bold;
font-style: italic;
}</pre>
</div>
<h3 id="plugins-backgroundgradient">Background gradient</h3><div>
<p class="abstract">
Converts proprietary gradient code into vendor-specific gradient code.
</p>
<p>
This plugin creates a cross-browser linear vertical or horizontal background gradient
(angles or radial gradient not supported). As this CSS3 property is still very alpha
we pick up W3C's current draft's syntax for a simple two-colored linear gradients.<br/>
For Mozilla, WebKit and Konquror we use their very differing vendor-specific gradient
implementation syntax, for Opera we assign a dynamically created SVG-file as background-image,
and for IE we make use of a gradient-filter.
</p>
<h4>Usage</h4>
<p>
Add <code>backgroundgradient</code> to your <code>@turbine</code> plugins rule and start using
<code>linear-gradient</code> following W3C's current draft's syntax for a simple two-colored
linear gradient within a <code>background-image</code> or <code>background</code> property:
</p>
<pre>
background: linear-gradient(<direction>,<startcolor>,<endcolor>);
</pre>
<h5>Possible values for the direction</h5>
<ul>
<li><code>top</code>: Gradient starting at the top, going to the bottom</li>
<li><code>left</code>: Gradient starting at the left, going to the right</li>
</ul>
<h5>Possible values for the colors</h5>
<ul>
<li>HEX, e.g. <code>#FFF</code></li>
<li>RGB, e.g. <code>rgb(255,255,255)</code></li>
<li>RGBA, e.g. <code>rgba(255,255,255,0.3)</code></li>
</ul>
<h4>Examples</h4>
<h5>Vertical gradient, from top to bottom, from white to black</h5>
<pre class="cssp">@turbine
plugins:backgroundgradient
#foo
background-image: linear-gradient(top,#FFF,#000)</pre>
<p>
Result for Mozilla:
</p>
<pre>#foo {
background-image: -moz-linear-gradient(top,#FFF,#000);
}
</pre>
<p>
Result for WebKit:
</p>
<pre>#foo {
background-image: -webkit-gradient(linear,left top,left bottom,from(#FFF),to(#000));
}
</pre>
<p>
Result for Konqueror:
</p>
<pre>#foo {
background-image: -khtml-gradient(linear,left top,left bottom,from(#FFF),to(#000));
}
</pre>
<p>
Result for Opera:
</p>
<pre>#foo {
background-image: url(/turbine/plugins/backgroundgradient/svg.php?direction=top&startcolor=#fff&endcolor=#000) 0 0 repeat;
}
</pre>
<p>
Result for IE 6 & 7: