一个轻量级的 Objective-C (需要 ARC 特性)模板引擎。
模板 ->
hello {{ name }},
you have just won {{ value}} !
please visit {{ site }} immediately.
给定哈希 ->
{
"name": "steve",
"value": "$100000",
"site": "www.cheatyouforever.com"
}
将产生 ->
hello steve,
you have just won $100000 !
please visit www.cheatyouforever.com immediately.
仅此而已。没有其他功能支持。
在您的 Podfile 中添加 pod 'CCTemplate'
以获取最新版本的 CCTemplate
#import "CCTemplate.h"
CCTemplate* engine = [[CCTemplate alloc] init];
NSString* template = @"hello world {{name}}";
id dict = @{@"name":@"xhan"};
NSString*result = [engine scan:template dict:dict];
// or just call nsstring category method
result = [template templateFromDict:dict];
@gearoidoceallaigh