<div class="container">
<div class="bucket-top-row row">
<?php
// get all the categories from the database
$cats = get_the_category();
// loop through the categries
foreach ($cats as $cat) {
// setup the cateogory ID
$cat_id= $cat->term_id;
// Make a header for the cateogry
// echo "<h2>".$cat->name."</h2>";
// create a custom wordpress query
query_posts("cat=$cat_id&posts_per_page=10");
// start the wordpress loop!
if (have_posts()) : while (have_posts()) : the_post();
?>
<div class="col-lg-4">
<div class="bucket-wrapper-standard-top-row">
<img class="image-bucket-standard" src="<?php echo get_template_directory_uri() . '/images/blog-images/hero-img-1.jpg'; ?>" />
<h4 id="post-<?php the_ID(); ?>" class="bucket-text-standard">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h4>
<p class="bucket-paragraph">
<?php /* the_permalink() */?>
</p>
<div class="author-text-bucket">
<div class="author-image six-sm">
<img class="author-img-post" src="<?php echo get_template_directory_uri() . '/images/author-headshots/fitness-mark.png'; ?>" />
</div> <span class="author-name-post-bucket "><?php> the_author(); ?></span>
<span class="bucket-category"><?php> the_category(); ?></span>
<div class="lower-bucket-text">
<span class="author-job-title-bucket "><?php> the_author_nickname(); ?></span>
<span class="bucket-read-time">3min read</span>
</div>
<div class="underline-bucket"></div>
</div>
</div>
</div>
<?php endwhile; endif; // done our wordpress loop. Will start again for each category ?>
<?php } // done the foreach statement ?>
</div>
FormatR обеспечивает подобные Perl форматы для Ruby.
Вот пример из документации:
require "formatr"
include FormatR
top_ex = <<DOT
Piggy Locations for @<< @#, @###
month, day, year
Number: location toe size
-------------------------------------------
DOT
ex = <<TOD
@) @<<<<<<<<<<<<<<<< @#.##
num, location, toe_size
TOD
body_fmt = Format.new (top_ex, ex)
body_fmt.setPageLength(10)
num = 1
month = "Sep"
day = 18
year = 2001
["Market", "Home", "Eating Roast Beef", "Having None", "On the way home"].each {|location|
toe_size = (num * 3.5)
body_fmt.printFormat(binding)
num += 1
}
Который производит:
Piggy Locations for Sep 18, 2001
Number: location toe size
-------------------------------------------
1) Market 3.50
2) Home 7.00
3) Eating Roast Beef 10.50
4) Having None 14.00
5) On the way home 17.50
Я, кажется, вспоминаю что-то подобное в Фортране, когда я использовал его много лет назад (однако, это может иметь, была сторонняя библиотека).
Что касается других опций в Perl взглянули на Perl6::Form
.
form
функциональные замены format
в Perl6. Damian Conway в "Лучших практиках Perl" рекомендует использовать Perl6::Form
с Perl5, цитирующим следующие проблемы с format
....
Вот a Perl6::Form
вариация на пример Ruby Robert Gamble....
use Perl6::Form;
my ( $month, $day, $year ) = qw'Sep 18 2001';
my ( $num, $numb, $location, $toe_size );
for ( "Market", "Home", "Eating Roast Beef", "Having None", "On the way home" ) {
push @$numb, ++$num;
push @$location, $_;
push @$toe_size, $num * 3.5;
}
print form
' Piggy Locations for {>>>}{>>}, {<<<<}',
$month, $day, $year ,
"",
' Number: location toe size',
' --------------------------------------',
'{]}) {[[[[[[[[[[[[[[[} {].0} ',
$numb, $location, $toe_size;
Существует Lisp (format ...)
функция. Это поддерживает цикличное выполнение, условные выражения и целый набор другого забавного материала.
например (скопированный с вышеупомянутой ссылки):
(defparameter *english-list*
"~{~#[~;~a~;~a and ~a~:;~@{~a~#[~;, and ~:;, ~]~}~]~}")
(format nil *english-list* '()) ;' ==> ""
(format nil *english-list* '(1)) ;' ==> "1"
(format nil *english-list* '(1 2)) ;' ==> "1 and 2"
(format nil *english-list* '(1 2 3)) ;' ==> "1, 2, and 3"
(format nil *english-list* '(1 2 3 4));' ==> "1, 2, 3, and 4"