artoodetoo/dirk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

artoodetoo/dirk

最新稳定版本:v1.0.1

Composer 安装命令:

composer require artoodetoo/dirk

包简介

PHP template system

README 文档

README

Tiny and powerfull template engine with syntax almost the same as in laravel/blade.

Installation

The package can be installed via Composer by requiring the "artoodetoo/dirk" package in your project's composer.json.

{
    "require": {
        "artoodetoo/dirk": "dev-master"
    }
}

Usage

/views/hello.dirk.html

@extends('layout/main')

<h1>Hello {{{ $name }}}!<h1>

{{ $timestamp or 'Timestamp not defined' }}

@section('sidebar')

  @foreach($list as $l)
    <p>{{ $l }} @if($l == 3) is equal 3 ! @endif</p>
  @endforeach

@endsection

/views/layout/main.dirk.html

<!DOCTYPE html>
<html>
<head>
<title>Example</title>
</head>
<body>

<sidebar>

@yield('sidebar', 'Default sidebar text')

</sidebar>

@yield('content')

</body>
</html>

/web/index.php

<?php

require 'vendor/autoload.php';

use R2\Templating\Dirk;

$view = new Dirk([
    'views' => __DIR__.'/views',
    'cache' => __DIR__.'/cache'
]);

$name = '<artoodetoo>';
$list = [1, 2, 3, 4, 5];

$view->render('hello', compact('name', 'list'));

Feature list

Echoes and comments

  • {{ $var }} - Echo. NOTE: it's escaped by default, like in Laravel 5!
  • {!! $var !!} - Raw echo without escaping
  • {{ $var or 'default' }} - Echo content with a default value
  • {{{ $var }}} - Echo escaped content
  • {{-- Comment --}} - A comment (in code, not in output)

Conditionals

  • @if(condition) - Starts an if block
  • @else
  • @elseif(condition)
  • @endif
  • @unless(condition) - Starts an unless block
  • @endunless

Loops

  • @foreach($list as $key => $val) - Starts a foreach block
  • @endforeach
  • @forelse($list as $key => $val) - Starts a foreach with empty block
  • @empty
  • @endforelse
  • @for($i = 0; $i < 10; $i++) - Starts a for block
  • @endfor
  • @while(condition) - Starts a while block
  • @endwhile

Inheritance and sections

  • @include(file) - Includes another template
  • @extends('layout') - Extends a template with a layout
  • @section('name') - Starts a section
  • @endsection - Ends section
  • @yield('section') - Yields content of a section.
  • @show - Ends section and yields its content
  • @stop - Ends section
  • @append - Ends section and appends it to existing of section of same name
  • @overwrite - Ends section, overwriting previous section of same name

License

The Dirk is open-source software, licensed under the MIT license

统计信息

  • 总下载量: 46
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-02-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固