htmlentities()
:echo HTML::entities('<h1>Title example</h1>');
nota : tikar '<' ke < dan '>' ke >
guna helper :
echo e('<h1>Title example</h1>');
2. Tukar HTML Entities ke String, php
html_entity_decode()
:$string HTML::decode('<h1>Hello</h1>');
3. Bina pautan ke fail Javascript :
{{ HTML::script('js/functions.js') }}
hasil :
<script src="http://your.url/js/functions.js"></script>
- atribute tambahan :
{{ HTML::script('js/functions.js', array('async' => 'async')) }}
hasil :
<script async="async" src="http://your.url/js/functions.js"></script>
4. Bina pautan ke fail CSS{{ HTML::style('css/style.css') }}
hasil :
<link media="all" type="text/css" rel="stylesheet"
href="http://your.url/css/style.css">
-dengan atribute tambahan
{{ HTML::style('css/style.css', array('media' => 'print')) }}
hasil :
<link media="print" type="text/css" rel="stylesheet"
href="http://your.url/css/style.css">
5. Bina elemen imej untuk HTML :
{{ HTML::image('img/picture.jpg') }}
hasil :
<img src="http://your.url/img/picture.jpg">
-tambah alt :
{{ HTML::image('img/picture.jpg', 'a picture') }}
hasil :
<img src="http://your.url/img/picture.jpg" alt="a picture">
- dengan atribute tambahan :
<img src="http://your.url/img/picture.jpg" class="thumb" alt="a picture">
6. Bina pautan untuk HTML :
{{ HTML::link('http://test.com') }}
hasil :
<a href="http://test.com">http://test.com</a>
- tambah title :
{{ HTML::link('http://test.com', 'testing')}}
hasil :
<a href="http://test.com">testing</a>
- tambah argument lain :
{{ HTML::link('http://test.com', null, array('id' => 'linkid'))}}
hasil :
<a href="http://test.com" id="linkid">http://test.com</a>
- tambah secure option :
{{ HTML::link('/login', 'log in', array('id' => 'linkid'), true)}}
hasil :
<a href="https://your.url/login" id="linkid">log in</a>
7. Bina pautan Secure HTML :
{{ HTML::secureLink('x') }}
hasil :
<a href="https://your.url/x">https://your.url/x</a>
- tambah title :
{{ HTML::secureLink('a/b', 'A-B') }}
hasil :
<a href="https://url.url/a/b">A-B</a>
- tambah lain atribute :
{{ HTML::secureLink('login', 'Sign In', array('class' => 'btn')) }}
hasil :
<a href="https://your.url/login" class="btn">Sign In</a>
8. Bina pautan asset HTML :
HTML::linkAsset()
nota : bergantung kepada kedudukan index.php
9. Bina pautan asset Secure HTML :
HTML::linkSecureAsset()
10. Bina pautan HTML ke nama Route :
{{ HTML::linkRoute('login') }}
hasil :
<a href="http://your.url/user/login">http://your.url/user/login</a>
- dengan atribute :
{{ HTML::linkRoute('login', 'Sign In') }}
hasil :
<a href="http://your.url/user/login">Sign In</a>
- dengan parameter :
{{ HTML::linkRoute('items.show', 'Show item #4', array(4)) }}
hasil :
<a href="http://your.url/items/4">Show item #4</a>
- tambahan parameter :
{{ HTML::linkRoute('login', 'Sign In', array(), array('class' => 'btn')) }}
hasil :
<a href="http://your.url/user/login" class="btn">Sign In</a>
11. Bina pautan HTML ke Controller Action :{{ HTML::linkAction('Home@index') }}
hasil :
<a href="http://your.url/index">http://your.url/index</a>
- dengan argument :
{{ HTML::linkAction('Home@index', 'Home') }}
hasil :
<a href="http://your.url/index">Home</a>
-degan parameter :
{{ HTML::linkAction('ItemController@show', 'Show Item #3', array(3)) }}
hasil :
<a href="http://your.url/items/3">Show Item #3</a>
- dengan atribute tambahan :
{{ HTML::linkAction('Home@index', 'Home', array(), array('class' => 'btn')) }}
hasil :
<a href="http://your.url/index" class="btn">Home</a>
12. Bina pautan HTML ke alamat Email :{{ HTML::mailto('a@b.c') }}
hasil :
<a href="mailto:a@ \
b.c">a@b.c</a>
- dengan
{{ HTML::mailto('a@b.c', 'Email Me') }}
hasil
<a href="mailto:a \
@b.c">Email Me</a>
- tambahan atribute :
{{ HTML::mailto('a@b.c', 'Email Me', array('class' => 'btn')) }}
hasil :
<a href="mailto: \
a@b.c" class="btn">Email Me</a>
13. Obfuscating alamat Email :
- tapisan untuk spam-bots.
$email = HTML::email('me@local.com');
hasil :
Email is <b>me@local.com</b>
14. Bina item untuk Ordered List :
{{ HTML::ol(array('a', 'b', 'c')) }}
hasil :
<ol>
<li>a</li>
<li>b</li>
<li>c</li>
</ol>
contoh sublist :
// PHP code to generate $list
$list = array(
'one',
'two',
array(
'sub-one',
'sub-two',
),
);
return View::make('thebladeview', array('list' => $list));
{{ HTML::ol($list) }}
hasil :
<ol>
<li>one</li>
<li>two</li>
<li><ol>
<li>sub-one</li>
<li>sub-two</li>
</ol></li>
</ol>
contoh 2 - sublist with title
// PHP code to generate $list
$list = array(
'one',
'two',
'three' => array(
'sub-one',
'sub-two',
),
);
return View::make('thebladeview', array('list' => $list));
{{ HTML::ol($list) }}
hasil :
<ol>
<li>one</li>
<li>two</li>
<li>three
<ol>
<li>sub-one</li>
<li>sub-two</li>
</ol>
</li>
</ol>
dengan atribute :
{{ HTML::ol(array('a', 'b'), array('class' => 'mylist')) }}
hasil :
<ol class="mylist">
<li>a</li>
<li>b</li>
</ol>
15. Bina item untuk Unordered List :
{{ HTML::ul(array('a', 'b', 'c'))}}
hasil :
<ul>
<li>a</li>
<li>b</li>
<li>c</li>
</ul>
-dengan sub list :
// PHP code to generate $list
$list = array(
'one',
'two',
array(
'sub-one',
'sub-two',
),
);
return View::make('thebladeview', array('list' => $list));
{{ HTML::ul($list) }}
hasil :
<ul>
<li>one</li>
<li>two</li>
<li>
<ul>
<li>sub-one</li>
<li>sub-two</li>
</ul>
</li>
</ul>
- sublist dengan title :
// PHP code to generate $list
$list = array(
'one',
'two',
'three' => array(
'sub-one',
'sub-two',
),
);
return View::make('thebladeview', array('list' => $list));
{{ HTML::ul($list) }}
<ul>
<li>one</li>
<li>two</li>
<li>three
<ul>
<li>sub-one</li>
<li>sub-two</li>
</ul>
</li>
</ul>
- dengan atribute
{{ HTML::ul(array('a', 'b'), array('class' => 'mylist')) }}
hasil :
<ul class="mylist">
<li>a</li>
<li>b</li>
</ul>
15. Bina HTML Attribute String dari Array :
echo HTML::attributes(array('id' => '123', 'class' => 'myclass'));
hasil :
id="123" class="myclass"
16. Obfuscating String :
{{-- Blade template --}}
{{ HTML::obfuscate('me@gmail.com') }}
me@gmail. \
com
No comments:
Post a Comment