Git Product home page Git Product logo

querytemplates's People

Watchers

 avatar

querytemplates's Issues

Using isset raises an error for objects

Report from Andreas Kalsch.

Following code from "output.code.php" causes "Fatal error: Cannot use object 
of type stdClass as array".

$d = new stdclass;
$d->a = 1;
var_dump(isset($d['a']));

Solution:

if (is_array($data) && isset($data['objs'])) $__242d2 = $data['objs']; else 
if (isset($data->{'objs'})) $__242d2 = $data->{'objs'}; 

Original issue reported on code.google.com by [email protected] on 28 Dec 2009 at 8:03

valuesToLoop

Static loop support.

$t['>ul > li']->valuesToLoop($d, function($row, $li1) {
    $node->valuesToSelector($row['User'], 'span.%k')->
        find('> ul')->
            valuesToLoop($row['Tags'], function($tag, $li2) {
                $li2->valuesToSelector($tag);
            })
    ;
});

Original issue reported on code.google.com by [email protected] on 24 Feb 2009 at 10:37

pq() inside template chain

pqt() shortcut to pq(), to easily wrap DOMNodes into QueryTemplates objects
(additional methods available).

Original issue reported on code.google.com by [email protected] on 24 Feb 2009 at 10:37

Robust JSON input support

Addign JSON input for template using one-line script.

Should support:
- passing thou pipe
- passing as parameter
-- more than one variable

Original issue reported on code.google.com by [email protected] on 27 Mar 2009 at 11:05

ifVar() varname must start with $, as opposite to the docs

What steps will reproduce the problem?
1.
find('div.comments')->ifVar('is_entry')

we have a var in context $in_entry=false

..not to show comments on index pages


What is the expected output? What do you see instead?

error in generated php code ... if(is_entry...)
instead of if($is_entry)...

workaround here is to use find('div.comments')->ifVar('$is_entry')

What version of the product are you using? On what operating system?

latest

Please provide any additional information below.

I find it a bit confusing writing variables with or without $, why not make it 
everywhere without the php $ ?

Original issue reported on code.google.com by [email protected] on 17 Sep 2010 at 2:49

File-less support

This mode wont need any file write-read, as it would use: 
eval('?>'.$code);

Original issue reported on code.google.com by [email protected] on 27 Apr 2009 at 6:30

Safer JS loops

Present JS loops doesn't skip inherited fields and are slower for arrays 
than they can be.

Todo:
 * use hasOwnProperty
 * use classic "for" loop for arrays

Original issue reported on code.google.com by [email protected] on 28 Dec 2009 at 8:18

Finish manual

Missing manual pages should be created. Existing checked and finished.


Original issue reported on code.google.com by [email protected] on 3 Dec 2008 at 2:20

Shorter API for simple template

This functionaliy:
->sourceCollect('input.html')  
  ->parse()  
    ->source('input.html')->returnReplace()

Will be equal to:
->parse('input.html')

Then shortest template will be like this:
template('output')->parse('input.html')  
  ->find('.my-div')  
    ->ifVar('showMyDiv')  
    ->find('ul > li')  
      ->loopOne('data', 'row')  
        ->varsToSelector('row', $rowFields)  
; 

Original issue reported on code.google.com by [email protected] on 23 Jan 2009 at 12:07

Bug in varPrintAttr()

What steps will reproduce the problem? Example:

1. $template->varPrintAttr('href', 'row.name')
2. Results in compiled code:
a) PHP: ... <a href="" class="name" row.name="<?php  if
(isset($row['name'])) print $row['name'];
else if (isset($row->{'name'})) print $row->{'name'};  ?>"> ...
b) JavaScript: ... <a href="" class="name" row.name="';
19
20 print(row['name']);
21;
22 __template += '"> ...

It seems that the documentation says, that
1) the first arg is the attribute's name,
2) and the second arg is the var name

Original issue reported on code.google.com by [email protected] on 28 Dec 2009 at 1:50

Paths along arrays and objects

When using paths to access the data tree, it is possible in PHP that some
are arrays and some are objects, so there must be made a distinction
between more than 2 cases in the compiled script. This is how it currently
looks like for "varPrint('data.foo.bar.0')"

<div>
     <p><?php  if (isset($data['foo']['bar']['0'])) print
$data['foo']['bar']['0'];
 else if (isset($data->{'foo'}->{'bar'}->{'0'})) print
$data->{'foo'}->{'bar'}->{'0'};  ?></p>
 </div>


Solution:

function find ($object, array $path) {

    if (!$path) return $object;

    $next = array_shift($path);

    if (is_array($object)) return isset($object[$next]) ? find($object[$next],
$path) : null;
    elseif (is_object($object)) return isset($object->$next) ?
find($object->$next, $path) : null;
    else return $object;
}

$a = array();
$a[]=array();
$a[0]['OK'] = new stdclass;
$a[0]['OK']->test = 0;
$a[0]['OK']->c = 1;

var_dump(find($a, array(0, 'OK', 'c', 'a')));


And now it looks like: 

<div>
     <p><?php print(find($data, array('foo', 'bar', '0'))); ?></p>
</div>

Original issue reported on code.google.com by [email protected] on 28 Dec 2009 at 2:11

toReference() should support active caching

When template is actively cached (void object is returned to simulate the
chain), toReference() doesn't change passed variable. This can lead up to
"Call to a member function ... on a non-object". Thus toReference called on
void object should also return void object.

Original issue reported on code.google.com by [email protected] on 15 Jan 2009 at 10:14

multi-var conditions

->ifVar('va1', 'var2')
->elseIfVar('va1', 'var2')

applies also to ifNotVar, elseIfNotVar

Original issue reported on code.google.com by [email protected] on 8 Mar 2009 at 12:58

JS: undefined checks

JS generator undefined checks are wrong:

typeof $var != undefined

Should be 

$var !== undefined

Original issue reported on code.google.com by [email protected] on 28 Dec 2009 at 8:16

Add HTML special char encoding to API

Values are just inserted plain text into the markup. This adds security issues.
To just escape object properties beforehand is possible, but I don't want
to use an own object just for templating (think of encoding the object to
JSON in the next step)

So what about adding extra methods or an additional argument to define, if
a value's special chars should be encoded?

Original issue reported on code.google.com by [email protected] on 28 Dec 2009 at 1:54

Support callbacks in data injection methods

Support callbacks in template filling methods

eg need to remove field's class name from node, after injecting data

$callbackRemoveClass = new Callback(
  create_function('$node, $fieldName', 'pq($node)->removeClass($fieldName);')
);
...->varsToSelector('variable', $fields, null, $callbackRemoveClass)->...

Original issue reported on code.google.com by [email protected] on 30 Dec 2008 at 1:58

PHP template formatter

Formatter should properly intend final code. There are already HTML Tidy
and XML_Beautifier integrations, but those have issues. Either this issues
will be solved or formatting in DOMDocument level will be achieved.

Original issue reported on code.google.com by [email protected] on 25 Dec 2008 at 11:29

Array support in form fieldnames

Support array fields in data injecting methods. By array fields i mean
ending with '[]' and creating array on the server side.

Original issue reported on code.google.com by [email protected] on 22 Dec 2008 at 10:51

Dynamic data filters

eg:
->varsFilter('htmlentities', 'stripslashes')

Applies callbacked filters to each variable injection.
Support last boolean parameter to switch 'sticky filter'.

Original issue reported on code.google.com by [email protected] on 24 Jan 2009 at 7:24

Patterns collection

Collection of QueryTemplates and jQuery-like patterns useful when dealing
with templates. Best place is probably the wiki.

Original issue reported on code.google.com by [email protected] on 3 Dec 2008 at 7:14

CSS stylesheet support

CSS stylesheet support can be used for Event Delegation directly from the
stylesheet to specially prepared methods. Simple mockup:

#browser.ie4 div.contents .section:load {
  stripTables: "odd-tr";
  modifySection: 10 arg1 "argument 2";
}

In this example selector is root for delegation with event stated at the
end. Properties are methods (what would class looks like ? :: ?) and
parameters are method's parameters, separated by space.

Additionally above example contains some browsercheck, which illustrates
another usecase for such functionality.

Probably best tool for this will be CSSTidy[1] with native PHP
implementation. Other possibility is PEAR class. Own implementation is also
considered.

[1] http://csstidy.sourceforge.net/

Original issue reported on code.google.com by [email protected] on 26 Jan 2009 at 12:04

Passive cache support

Actual cache method (1.0 beta2) caches only internal QueryTemplates code
and supplied callbacks. Every code executed before going into template
chain is executed always, also when template is read from cache. That's why
new cache method should be available to target this issue. Consider
following code:

require templateFile('my-template-formula.php', __FILE__);

Unfortunately this would NOT work with $monitorCodeModification and
$monitorSourceModification, only with $cacheTimeout. __FILE__ is needed for
determining templates path. 

Original issue reported on code.google.com by [email protected] on 15 Jan 2009 at 11:34

nested var names

support quoting var names to not be quoted as strings ex
  'obj.param.`scopeVar`.subkey'
would became
  $obj->param->{$scopeVar}->subkey;

Original issue reported on code.google.com by [email protected] on 8 Mar 2009 at 12:57

varsFilter method

Cascade-inherited filter declaration:

$dom['div']->varsFilter('htmlentities', 'stripslashes');
$dom['div p']->varPrint('foo');

Would result in:

<div>
  <p><?php print htmlentities(stripslashes($foo)); ?></p>
</div>

Original issue reported on code.google.com by [email protected] on 27 Mar 2009 at 11:17

ifVarIsset() method

->ifVarIsset('var.name')
->ifVarNotIsset('var.name')
->elseIfVarIsset
->elseIfNotVarIsset

Original issue reported on code.google.com by [email protected] on 8 Mar 2009 at 12:55

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.