当前位置: 首页>>代码示例>>PHP>>正文


PHP Timber::compile_string方法代码示例

本文整理汇总了PHP中Timber::compile_string方法的典型用法代码示例。如果您正苦于以下问题:PHP Timber::compile_string方法的具体用法?PHP Timber::compile_string怎么用?PHP Timber::compile_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Timber的用法示例。


在下文中一共展示了Timber::compile_string方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testTermToString

 function testTermToString()
 {
     $term_id = $this->factory->term->create(array('name' => 'New England Patriots'));
     $term = new TimberTerm('new-england-patriots');
     $str = Timber::compile_string('{{term}}', array('term' => $term));
     $this->assertEquals('New England Patriots', $str);
 }
开发者ID:mrgrain,项目名称:timber,代码行数:7,代码来源:test-timber-term.php

示例2: testTwigFilterDateWordPressOption

 function testTwigFilterDateWordPressOption()
 {
     $format = get_option('date_format');
     $str = Timber::compile_string("{{now|date('" . $format . "')}}");
     $empty = Timber::compile_string("{{now|date}}");
     $this->assertSame($str, $empty);
 }
开发者ID:rd-alex-alex2006hw,项目名称:timber,代码行数:7,代码来源:test-timber-twig-filters.php

示例3: testACFGetFieldTermTag

 function testACFGetFieldTermTag()
 {
     $tid = $this->factory->term->create();
     update_field('color', 'green', 'post_tag_' . $tid);
     $term = new TimberTerm($tid);
     $str = '{{term.color}}';
     $this->assertEquals('green', Timber::compile_string($str, array('term' => $term)));
 }
开发者ID:Butterwell,项目名称:timber,代码行数:8,代码来源:test-timber-integrations.php

示例4: testLinkOnSubdirectoryInstall

 function testLinkOnSubdirectoryInstall()
 {
     update_option('siteurl', 'http://example.org/wordpress', true);
     $context = Timber::get_context();
     $theme = $context['site']->theme;
     $output = Timber::compile_string('{{site.theme.link}}', $context);
     $this->assertEquals('http://example.org/wp-content/themes/' . $theme->slug, $output);
 }
开发者ID:Butterwell,项目名称:timber,代码行数:8,代码来源:test-timber-theme.php

示例5: testGetData

 function testGetData()
 {
     $_GET['foo'] = 'bar';
     $template = '{{request.get.foo}}';
     $context = Timber::get_context();
     $str = Timber::compile_string($template, $context);
     $this->assertEquals('bar', $str);
 }
开发者ID:mrgrain,项目名称:timber,代码行数:8,代码来源:test-timber-request.php

示例6: testTypeMethodInTwigLabels

 function testTypeMethodInTwigLabels()
 {
     $post_id = $this->factory->post->create();
     $post = new TimberPost($post_id);
     $template = '{{post.type.labels.name}}';
     $str = Timber::compile_string($template, array('post' => $post));
     $this->assertEquals('Posts', $str);
 }
开发者ID:mrgrain,项目名称:timber,代码行数:8,代码来源:test-timber-post-type.php

示例7: testPreviewWithSpaceInMoreTag

 function testPreviewWithSpaceInMoreTag()
 {
     $pid = $this->factory->post->create(array('post_content' => 'Lauren is a duck, but a great duck let me tell you why <!--more--> Lauren is not a duck', 'post_excerpt' => ''));
     $post = new TimberPost($pid);
     $template = '{{post.preview.length(3).force}}';
     $str = Timber::compile_string($template, array('post' => $post));
     $this->assertEquals('Lauren is a&hellip; <a href="' . $post->link() . '" class="read-more">Read More</a>', $str);
 }
开发者ID:mrgrain,项目名称:timber,代码行数:8,代码来源:test-timber-post-preview-object.php

示例8: testImageResizeRetinaFilterNotAnImage

 function testImageResizeRetinaFilterNotAnImage()
 {
     self::enable_error_log(false);
     $str = 'Image? {{"/wp-content/uploads/2016/07/stuff.jpg"|retina(3)}}';
     $compiled = Timber::compile_string($str);
     $this->assertEquals('Image? /wp-content/uploads/2016/07/stuff.jpg', $compiled);
     self::enable_error_log(true);
 }
开发者ID:jarednova,项目名称:timber,代码行数:8,代码来源:test-timber-image-retina.php

示例9: testPostCustomFieldPropertyConflict

 function testPostCustomFieldPropertyConflict()
 {
     $post_id = $this->factory->post->create(array('post_title' => 'foo'));
     update_post_meta($post_id, 'post_title', 'bar');
     $post = new TimberPost($post_id);
     $str = '{{post.title}}';
     $result = Timber::compile_string($str, array('post' => $post));
     $this->assertEquals('foo', $result);
 }
开发者ID:mrgrain,项目名称:timber,代码行数:9,代码来源:test-timber-custom-fields.php

示例10: testUnderscoreTypeCustomField

 function testUnderscoreTypeCustomField()
 {
     $post_id = $this->factory->post->create();
     update_post_meta($post_id, '_type', 'numberwang');
     $post = new TimberPost($post_id);
     $template = '{{post._type}}';
     $str = Timber::compile_string($template, array('post' => $post));
     $this->assertEquals('numberwang', $str);
 }
开发者ID:jarednova,项目名称:timber,代码行数:9,代码来源:test-timber-post-type.php

示例11: testModifiedTimeFilter

 function testModifiedTimeFilter()
 {
     $pid = $this->factory->post->create();
     $post = new TimberPost($pid);
     add_filter('get_the_modified_time', function ($the_date) {
         return 'foobar';
     });
     $twig = "I was modified {{post.modified_time('F j, Y @ g:i a')}}";
     $str = Timber::compile_string($twig, array('post' => $post));
     $this->assertEquals('I was modified foobar', $str);
 }
开发者ID:rjagadishsingh,项目名称:timber,代码行数:11,代码来源:test-timber-dates.php

示例12: testDescription

 function testDescription()
 {
     $uid = $this->factory->user->create(array('display_name' => 'Baberaham Lincoln'));
     update_user_meta($uid, 'description', 'Sixteenth President');
     $user = new TimberUser($uid);
     $this->assertEquals('Sixteenth President', $user->description);
     $pid = $this->factory->post->create(array('post_author' => $uid));
     $post = new TimberPost($pid);
     $str = Timber::compile_string('{{post.author.description}}', array('post' => $post));
     $this->assertEquals('Sixteenth President', $str);
 }
开发者ID:rjagadishsingh,项目名称:timber,代码行数:11,代码来源:test-timber-user.php

示例13: testJPEGtoJPG

 function testJPEGtoJPG()
 {
     $filename = TestTimberImage::copyTestImage('jarednova.jpeg');
     $str = Timber::compile_string('{{file|tojpg}}', array('file' => $filename));
     $renamed = str_replace('.jpeg', '.jpg', $filename);
     $this->assertFileExists($renamed);
     $this->assertGreaterThan(1000, filesize($renamed));
     $this->assertEquals('image/jpeg', mime_content_type($filename));
     $this->assertEquals('image/jpeg', mime_content_type($renamed));
     unlink($filename);
     unlink($renamed);
 }
开发者ID:BernsteinA,项目名称:timber,代码行数:12,代码来源:test-timber-image-tojpg.php

示例14: testCommentWithChildren

 function testCommentWithChildren()
 {
     $kramer = $this->factory->user->create(array('display_name' => 'Cosmo Kramer'));
     $post_id = $this->factory->post->create();
     $comment_id = $this->factory->comment->create(array('comment_post_ID' => $post_id, 'comment_content' => 'These pretzels are making me thirsty.', 'user_id' => $kramer));
     sleep(2);
     $comment_id = $this->factory->comment->create(array('comment_post_ID' => $post_id, 'comment_content' => 'Perhaps there’s more to Newman than meets the eye.'));
     $child_id = $this->factory->comment->create(array('comment_post_ID' => $post_id, 'comment_content' => 'No, there’s less.', 'comment_parent' => $comment_id));
     $post = new TimberPost($post_id);
     $comments = $post->get_comments();
     $this->assertEquals(2, count($comments));
     $this->assertEquals(1, count($comments[1]->children));
     $twig_string = '{{comment.author.name}}';
     $result = Timber::compile_string($twig_string, array('comment' => $comments[0]));
     $this->assertEquals('Cosmo Kramer', $result);
 }
开发者ID:xavivars,项目名称:timber,代码行数:16,代码来源:test-timber-comment.php

示例15: testImageResizeRetinaFilter

 function testImageResizeRetinaFilter()
 {
     $filename = TestTimberImage::copyTestImage('eastern.jpg');
     $wp_filetype = wp_check_filetype(basename($filename), null);
     $post_id = $this->factory->post->create();
     $attachment = array('post_mime_type' => $wp_filetype['type'], 'post_title' => preg_replace('/\\.[^.]+$/', '', basename($filename)), 'post_excerpt' => '', 'post_status' => 'inherit');
     $attach_id = wp_insert_attachment($attachment, $filename, $post_id);
     add_post_meta($post_id, '_thumbnail_id', $attach_id, true);
     $data = array();
     $data['post'] = new TimberPost($post_id);
     $str = '{{post.thumbnail.src|resize(100, 50)|retina(3)}}';
     $compiled = Timber::compile_string($str, $data);
     $img = new TimberImage($compiled);
     $this->assertContains('@3x', $compiled);
     $this->assertEquals(300, $img->width());
 }
开发者ID:rjagadishsingh,项目名称:timber,代码行数:16,代码来源:test-timber-image-retina.php


注:本文中的Timber::compile_string方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。