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
/
Copy pathdocs-11.php.html
2661 lines (2549 loc) · 93.9 KB
/
docs-11.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:"3fadcfc4f1e6815fb3fd88e9603ef1ef41688471-1448330138-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-11.php.html#intro">Introduction</a>
<ul>
<li><a href="docs-11.php.html#intro-goalsandfeatures">Goals and Features</a></li>
</ul>
</li>
<li>↓ <a href="docs-11.php.html#usage">Usage</a>
<ul>
<li><a href="docs-11.php.html#usage-setup">Installation and setup</a></li>
<li><a href="docs-11.php.html#usage-editor">Editor setup</a></li>
<li><a href="docs-11.php.html#usage-syntax">Basic syntax</a></li>
<li><a href="docs-11.php.html#usage-configuration">Configuration</a></li>
<li><a href="docs-11.php.html#usage-advanced">Advanced syntax</a></li>
<li><a href="docs-11.php.html#usage-paths">Paths</a></li>
<li><a href="docs-11.php.html#usage-constantsaliases">Constants and aliases</a></li>
<li><a href="docs-11.php.html#usage-inheritancetemplating">Inheritance and prototyping</a></li>
</ul>
</li>
<li>↓ <a href="docs-11.php.html#plugins">Core Plugins</a>
<ul>
<li><a href="docs-11.php.html#plugins-fontface">@font-face</a></li>
<li><a href="docs-11.php.html#plugins-backgroundgradient">Background gradient</a></li>
<li><a href="docs-11.php.html#plugins-borderradius">Border radius</a></li>
<li><a href="docs-11.php.html#plugins-boxshadow">Box shadow</a></li>
<li><a href="docs-11.php.html#plugins-boxsizing">Box sizing</a></li>
<li><a href="docs-11.php.html#plugins-sniffer">Browser and platform sniffer</a></li>
<li><a href="docs-11.php.html#plugins-bugfix">Browser bugfixes</a></li>
<li><a href="docs-11.php.html#plugins-color">Color</a></li>
<li><a href="docs-11.php.html#plugins-datauri">Data URIs</a></li>
<li><a href="docs-11.php.html#plugins-inlineblock">Inline block</a></li>
<li><a href="docs-11.php.html#plugins-load">Load</a></li>
<li><a href="docs-11.php.html#plugins-minifier">Minifier</a></li>
<li><a href="docs-11.php.html#plugins-opacity">Opacity</a></li>
<li><a href="docs-11.php.html#plugins-quote">Quote style</a></li>
<li><a href="docs-11.php.html#plugins-reset">Reset stylesheet</a></li>
<li><a href="docs-11.php.html#plugins-transforms">Transforms</a></li>
<li><a href="docs-11.php.html#plugins-meta">Meta plugins</a></li>
</ul>
</li>
<li>↓ <a href="docs-11.php.html#dev">Development</a>
<ul>
<li><a href="docs-11.php.html#dev-contribute">Contribute</a></li>
<li><a href="docs-11.php.html#dev-plugins">Plugin development</a></li>
<li><a href="docs-11.php.html#dev-styleguide">Style guide</a></li>
</ul>
</li>
<li>↓ <a href="docs-11.php.html#tools">Tools</a>
<ul>
<li><a href="docs-11.php.html#tools-converter">Converter</a></li>
<li><a href="docs-11.php.html#tools-shell">Shell</a></li>
</ul>
</li>
<li>↓ <a href="docs-11.php.html#faq">FAQ</a>
<ul>
<li><a href="docs-11.php.html#faq-why">Why use Turbine?</a></li>
<li><a href="docs-11.php.html#faq-tradeoffs">What are the tradeoffs?</a></li>
<li><a href="docs-11.php.html#faq-static">Non-server environments?</a></li>
<li><a href="docs-11.php.html#faq-performance">What about performance?</a></li>
<li><a href="docs-11.php.html#faq-projects">Ready for real projects?</a></li>
<li><a href="docs-11.php.html#faq-cache">Disable the Cache?</a></li>
<li><a href="docs-11.php.html#faq-cssp">What's CSSP?</a></li>
<li><a href="docs-11.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.1</em>, which is currently in beta state. This document may be slightly out of date. You can find the docs for the 1.0 branch in the <a href="docs.php.html">current 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="turbine">// 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;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
-khtml-border-radius: 4px;
border-radius: 4px;
}
}</pre>
<p>
…or, if you like fast-loading websites, directly into this (which is automatically cached on the server, gezipped and served with the correct expires headers):
</p>
<pre>@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>
<tr>
<td><code>expire_in_future</code></td>
<td>Set expire header in seconds</td>
<td><code>0</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>Multiple websites</h4>
<p>
If you want to use the same Turbine installation on multiple websites you can modify the configuration for each site by simply hacking
<code>config.php</code> to suit your needs. See the file for details and an example.
</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>. They are processed by the
Turbine compiler and the result is then output as CSS code. Thus, a <code><link></code> element must be added to your HTML.
</p>
<h5>Add the <code><link></code> element manually</h5>
<p>
One way to use Turbine is to 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>
<h5>Auto-generate the <code><link></code> element</h5>
<p>
As of 1.1.0 Turbine can generate it's own embedding code. Simply include <code>/inc/turbine.php</code> and add the <code>turbine()</code>
function in your document's <code><head></code>. The function takes up to four arguments:
</p>
<ol>
<li>The path to css.php relative to the document. Defaults to 'css.php'.</li>
<li>An array of .cssp files relative to the base dir. Defaults to an empty array.</li>
<li>A string that is either <code>xhtml</code> or <code>html</code>, depending on whether you want XHTML or HTML output. Defaults to <code>xhtml</code>.</li>
<li>A value for the <code><link></code> element's <code>media</code> attribute. Defaults to an empty string (which results in no <code>media</code>
attribute being printed at all).</li>
</ol>
<p>
Example:
</p>
<pre><?php
include('inc/turbine.php');
turbine('css.php', array(
'style/layout.cssp',
'style/design.cssp'
), 'xhtml', 'projection');
?></pre>
<p>
Result:
</p>
<pre><link rel="stylesheet" href="css.php?files=style/layout.cssp;style/design.cssp" media="projection" /></pre>
<p>
If you want the HTML returned rather than printed out directly, use the <code>get_turbine()</code> function with the same arguments as for
<code>turbine()</code>.
</p>
<h5>Things to keep in mind</h5>
<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 are processed in sequence and <strong>don't</strong> influence each other in any way. For example,
<a href="docs-11.php.html#usage-constantsaliases">constants</a> defined in <code>fileA</code> won't apply to code in <code>fileB</code>. If
you want share code between files, use the <a href="docs-11.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-11.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="turbine">#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="turbine">#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-11.php.html#usage-nested">nested selectors</a>).
You can use tabs or any number of spaces for indentation, but be careful to keep your indentation constistent in the whole
file. Turbine will report indentation errors and try to fix files where tabs and spaces are mixed, but it's better not to depend on this.
</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="turbine">#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="turbine">// 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="turbine">--
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="turbine">@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="turbine">@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 are 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-11.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-11.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-11.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-11.php.html#usage-inheritancetemplating-templating">Templating</a>)</td>
</tr>
<tr>
<th rowspan="2">&</th>
<td>Selector</td>
<td>Placeholder for use in nested selectors</td>
</tr>
<tr>
<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 four things that can be controlled there: css compression, plugins, plugin options and the stylesheet's title.
</p>
<h4>CSS compression</h4>
<p>
Turbine can output CSS code in a minified form:
</p>
<pre class="turbine">@turbine
compress:1
#foo
color:red
background:blue</pre>
<p>
Becomes
</p>
<pre>#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="turbine">@turbine
plugins:resetstyle, datauri, borderradius</pre>
<p>
Turbine has a set of <a class="smoothscroll" href="docs-11.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-11.php.html#dev-plugins">easily build your own plugins</a>.
</p>
<h4>Plugin options</h4>
<p>
Some plugins have configuration options. To use them, simply add the plugin's name as a property to the <code>@turbine</code> block
and list the options you want to use as values. If for example the filters that simulate <code>box-shadow</code> in Internet Explorer
are too ugly for your liking, you can pass a <code>noie</code> option to the <a href="docs-11.php.html#plugins-boxshadow" class="smoothscroll">box
shadow plugin</a>:
</p>
<pre class="turbine">@turbine
plugins:boxshadow
boxshadow:noie // Don't display box shadows in IE</pre>
<h4>Title</h4>
<p>
A stylesheet's title may be set via the <code>title</code> property of the <code>@turbine</code> element. The title is displayed as a
css comment in the header of the final output. To add more lines to the title, just add multiple <code>title</code> properties:
</p>
<pre class="turbine">@turbine
title: Design for Project XYZ
title: © 2010 Company Inc.
title: All rights reserved</pre>
<p>
Result:
</p>
<pre class="comment">/*
Design for Project XYZ
© 2010 Company Inc.
All rights reserved
Stylesheet generated by Turbine - http://turbine.peterkroener.de/
*/</pre>
</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="turbine">#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 id="nested-selectors">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="turbine">#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="turbine">#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>
<p>
Selectors like this are of course a little inefficent, but the increase in performance should be worth the resulting minor performance
penalty in most cases. Several of Turbine's other features can help to migitate the performance impact (see <a class="smoothscroll" href="docs-11.php.html#faq-performance">FAQ</a>).
</p>
<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="turbine">#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>Generated selectors</h4>
<p>
Turbine can generate selectors from a shorthand syntax to save you some more typing.
</p>
<h5>Numbered selectors</h5>
<p>
If you want to match elements with numbered classes oder IDs you can generate the selectors for a range of numerical values:
</p>
<pre class="turbine">div.number(1-8)
color:red
span.number(8-4) // Counting backwards works too!
color:blue</pre>
<p>
Result:
</p>
<pre class="css">div.number1, div.number2, div.number3, div.number4, div.number5, div.number6, div.number7, div.number8 {
color: red;
}
span.number8, span.number7, span.number6, span.number5, span.number4 {
color: blue;
}</pre>
<h5>Combined selectors</h5>
<p>
Similar to numbered selectors, selectors can be combined from lists of strings:
</p>
<pre class="turbine">a[href](:hover, :active, :focus)
text-decoration:none
div.container-(alpha, beta, gamma)
font-weight:bold</pre>
<p>
Result:
</p>
<pre class="css">a[href]:hover, a[href]:active, a[href]:focus {
text-decoration: none;
}
div.container-alpha, div.container-beta, div.container-gamma {
font-weight: bold;
}</pre>
<h5>Referenced nested selectors</h5>
<p>
Turbine's <a href="docs-11.php.html#nested-selectors">nested selectors</a> sepperate their parts with a space character. If you don't want that,
you can use the <code>&</code> character as a placeholder for the parent selector:
</p>
<pre class="turbine">a
font-weight:bold
&:link, &:visited
text-decoration:underline
&:hover, &:active
text-decoration:none
&:focus
outline:1px solid #CCC
text-decoration:none</pre>
<p>
Result:
</p>
<pre class="css">a {
font-weight: bold;
}
a:link, a:visited {
text-decoration: underline;
}
a:hover, a:active {
text-decoration: none;
}
a:focus {
outline: 1px solid #CCC;
text-decoration: none;
}</pre>
<h5>All at once</h5>
<p>
The various methods of selector generation can of course be combined:
</p>
<pre class="turbine">div.(post, article)-(1-5)
&-even
color:red
&-odd
color:blue</pre>
<p>
Result:
</p>
<pre class="css">div.post-1-even, div.article-1-even, div.post-2-even, div.article-2-even, div.post-3-even, div.article-3-even, div.post-4-even, div.article-4-even, div.post-5-even, div.article-5-even {
color: red;
}
div.post-1-odd, div.article-1-odd, div.post-2-odd, div.article-2-odd, div.post-3-odd, div.article-3-odd, div.post-4-odd, div.article-4-odd, div.post-5-odd, div.article-5-odd {
color: blue;
}</pre>
<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="turbine">@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="turbine">@constants
myRed:#C02222
imagePath:/assets/images
#foo
color:$myRed
background:url($imagePath/foo.png) top left no-repeat</pre>
<p>
Result:
</p>
<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="turbine">@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="turbine">@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. <strong>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.</strong> Inheritance and Prototyping only works within the same <code>@media</code> blocks.
</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="turbine">#foo
color:#F00
#bar
color:copy(#foo color)</pre>
<p>
Result:
</p>
<pre class="css">#foo {
color: #F00
}
#bar {
color: #F00
}</pre>
<p>
The copied and copying properties don't have to be the same:
</p>
<pre class="turbine">#foo
background:#F00
#bar
color:copy(#foo background)</pre>
<p>
Result:
</p>
<pre class="css">#foo {
color: #F00
}
#bar {
background: #F00
}</pre>
<p>
Copying works with aliases too. If you want to copy the <code>color</code> value from <code>$foo</code> to <code>#bar</code>, you can simply use
<code>copy($foo color)</code>:
</p>
<pre class="turbine">@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="turbine">#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 an element <code>extends</code> will <strong>not</strong> overwrite it:
</p>
<pre class="turbine">#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="turbine">#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>
<h4 id="usage-inheritancetemplating-labels">Using labels</h4>
<p>
To inherit properties from an element with a generated selector the whole generated selector must be used for the <code>extends</code> property, which
can be problematic. Consider the following:
</p>
<pre class="turbine">#foo, #bar
h(1-6)
color:red</pre>
<p>
To inherit from the resulting element, one would have to figure out the selector that gets generated and use it for the <code>extends</code> property:
</p>
<pre class="turbine">// This is ridiculous
#extending
extends: #foo h1, #foo h2, #foo h3, #foo h4, #foo h5, #foo h6, #bar h1, #bar h2, #bar h3, #bar h4, #bar h5, #bar h6</pre>
<p>
This can become a bit unwieldy and ultimatly defeat the propose of generated selectors. Turbine 1.1 intoduces a new <code>label</code> property that
can be used for any element to serve as something like an inmutable selector for extending:
</p>
<pre class="turbine">#foo, #bar
h(1-6)
color:red
label:myelement // Declare a label
#extending
extends:myelement // Much shorter than the entire selector!</pre>
<p>
This works just as well as using the selector. The <code>label</code> property is invisible in the final output and is never copied or inherited itself.
It is possible to declare a label more than once:
</p>
<pre class="turbine">#foo, #bar
h(1-6)
color:red
label:myelement