Can ns() provide push/pull using some kind of passed variable? This should be documented one way or the other. Current documentation isn't entirely clear.

Comments

Todd Nienkerk’s picture

Title: Document/determine if contetual use of ns() can be extended to supply push/pull classes » Document/determine if contextual use of ns() can be extended to supply push/pull classes

Fixing typo in title.

dvessel’s picture

Passed variable as which argument?

Taking this example from the readme file:

<div class="container-16">
  <div id="main" class="<?php print ns('grid-16', $neighbor_a, 3, $neighbor_b, 4); ?>">
    <?php print $main; ?>              [default]      |        |      |        |
  </div>                                              |- pair -|      |- pair -|
                                                      |        |      |        |
  <?php if ($neighbor_a): ?> <!-----------------------/        |      |        |
  <div id="neighbor-a" class="grid-3"> <!----------------------/      |        |
    <?php print $neighbor_a; ?>                                       |        |
  </div>                                                              |        |
  <?php endif; ?>                                                     |        |
                                                                      |        |
  <?php if ($neighbor_b)?> <!-----------------------------------------/        |
  <div id="neighbor-b" class="grid-4"> <!--------------------------------------/
    <?php print $neighbor_b; ?>
  </div>
  <?php endif; ?>
</div>

The second and the optional fourth is expected to be a variable to do its subtractive checking. The others can be from a variable also as long as you feed it the expected type of values.

The first parameter must be a string delimited with a hyphen ending in a numeric. "foo-23" would be processed just as well as "pull-10" or "grid-8". The function is very generic so the prefix string can be pretty much anything. [prefix]-[num]