Mustacheクラスを拡張せずにテンプレートから$ stringまたはHelloWorld :: getString()にアクセスするためのベストプラクティスをお勧めしますか?口ひげ(php)とオブジェクト?
<?php
Class HelloWorld{
protected $string;
function __construct(){
$this->string = 'Hello World';
}
function setString($str) { $this->string = $str; }
function getString() { return $this->string; }
}
# here goes nothing
$h = new HelloWorld();
$m = new Mustache();
echo $m->render('{{string}}', $h);
?>
あなたが想像している通り、私が$ stringをpublicにすると、期待通りに動作します。私は何が欠けていますか?
これは本当に "私は何が足りないですか"という質問に答えるのに役立ちました。ありがとうございました。問題は、Mustacheを使って作業している間に解決策ではないように見えることです。 – Mike