badcow/ink
Composer 安装命令:
composer require badcow/ink
包简介
A Twig powered WordPress template builder.
README 文档
README
#Ink WordPress Starter Theme
##What is Ink? Ink is a WordPress starter theme that harnesses the power of the Twig template engine to build readable WordPress templates.
##Why Ink? First, and foremost, PHP is not a template engine! If you would like to disagree, please read this blog before arguing.
"If you think PHP is still a template language, can you give me just one recent change in the PHP language which enhanced PHP as a template language? I cannot think of one."
PHP is a dynamic language that started its life as a template engine, but has grown into a powerful, community-orientated language. PHP is no longer a templating language. Smarty, Django, HAML and Twig are templating languages.
##If you decide to use Ink, you are not stuck with Twig. This is, by no means, and exhaustive replacement for traditional WordPress templates. If there is something that Ink cannot (yet) do that PHP does, you can still use a normal template file.
##Installing Ink Get Composer composer.phar install badcow/ink
##Compare Twig to PHP Below we will compare two files that both achieve the same thing; they both render a page and list other pages. The first example uses Twig, the second uses PHP.
###Twig syntax
{% extends 'base.html.twig' %}
{% block content %}
<section>
<h1>{{ post.title }}</h1>
<em>{{ post.date.format('d/m/Y') }}</em><br />
{{ post.content }}
<h1>List of posts</h1>
{% set posts = postQuery.getPosts('post_type=page') %}
{%for posty in posts %}
<h2>{{posty.title}}</h2>
{{posty.content | raw}}
<hr />
{% else %}
<em>There are no posts to be displayed, sorry.</em>
{% endfor %}
</section>
{% endblock %}
###PHP syntax
<?php get_header(); ?>
<section>
<h1><?php the_title(); ?></h1>
<?php the_date('d/m/Y', '<em>', '</em>'); ?><br />
<?php the_content(); ?>
<h1>List of posts</h1>
<?php
$posts = new WP_Query('post_type=page');
if($posts->have_posts()):
while($posts->have_posts()): $posts->the_post();
?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<hr />
<?php endwhile; ?>
<?php else: ?>
<em>There are no posts to be displayed, sorry.</em>
<?php endif; ?>
</section>
<?php get_footer(); ?>
The advantage of Twig is that the syntax is more fluid and is closer to HTML than to PHP. In templating using PHP, it becomes a monstrous task to keep track of all the loop beginnings and endings.
badcow/ink 适用场景与选型建议
badcow/ink 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 25 次下载、GitHub Stars 达 1, 最近一次更新时间为 2013 年 01 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 badcow/ink 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 badcow/ink 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 25
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 30
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2013-01-22