定制 flsouto/render 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

flsouto/render

Composer 安装命令:

composer require flsouto/render

包简介

HTML5 Document boilerplate

README 文档

README

Outputs an html5 document with a title and a body. UTF-8 encoding is assumed.

Installation

Install it via composer:

composer require flsouto/render

Usage

Pass the page's title and body as arguments to the render function:

<?php
require_once('vendor/autoload.php');
render('HTML5 Boilerplate', 'This is just a test');

Output:

<!DOCTYPE html>
<html>
	<head>
		<title>Testing the Lib</title>
		<meta charset="UTF-8">
	</head>
	<body>
		This is just a test 
	</body>
</html>

Using closures

The content doesn't need to be a string. Instead, you can provide a callback that generates the content:

<?php
require_once('vendor/autoload.php');
render('HTML5 Boilerplate', function(){
	return "This is a test";
});

Will produce the same html output as above.

Return or Output?

Your callback can either return the content or print something out. This is good because you can use alternative markup syntax inside a closure:

<?php
require_once('vendor/autoload.php');
render('HTML5 Boilerplate', function(){?>
	
	<div id="main">
		<h1>Example</h1>		
		<b>Output some markup</b>
	</div>

<?php });

Output:

<html>
	<head>
		<title>HTML5 Boilerplate</title>
		<meta charset="UTF-8">
	</head>
	<body>	
	<div id="main">
		<h1>Example</h1>		
		<b>Output some markup</b>
	</div>
	</body>
</html>

Extending this Library

This is good enough to get you started quickly. However, as your project becomes more complex and you need to further customize the document, let's say, add some extra meta tags or change the document's charset, then you will need something different. What can you do after you have several pages relying on the implementation of the simplistic render function? Here is what you do: you copy the function from the vendor directory to your project's (it's really just one file/function), change the implementation as desired and then remove this package from your composer installation. Done.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2016-10-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固