D
D
dk-web2015-09-06 17:25:46
PHP
dk-web, 2015-09-06 17:25:46

What are you creating php/tpl/html templates in?

I wrote a treatise and deleted it .. very briefly.
I really liked Jade. I only use it as a syntax shorthand. Killed a lot of time and broke many brains how to marry them with php tags. But there is no final result. Everything rested .. do not believe in the banal lack of transfers to a new line.

<div class="slogan"><?php if ($test == 0): ?>
          <p>Test zero</p><?php elseif ($test == 1): ?>
          <p>Test one</p><?php else: ?>
          <p>Other test</p><?php endif; ?>
        </div>

If only it could be tolerated. then there would be no price and I would be happy.
But...
I put Emmet in Sublime2... but it's still not right...
I tried to write under smarty - {...} - also doesn't eat jade (
I'm sure that since this question arises only for me. just solved ...
Once again ... I just really liked the Jade-Sass bundle (tab, simplified syntax) and all the goodies from Gulp to this .. but PHP doesn’t fit in here at all ...

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey, 2015-09-06
Protko @Fesor

but PHP doesn't fit in here...

exactly.
There are modules in js , there are solutions in php . You choose what and how to use.
I somehow thought about adding jade / haml support to twig, since it allows you to do this due to its flexibility, but since I don’t often write templates for php (I’ve separated the frontend and backend for more than a year and settled between them rest), somehow it failed.

N
Nazar Mokrinsky, 2015-09-06
@nazarpc

I use web components, I write templates myself in haml with automatic conversion to html.
Polymer allows you to get rid of such mess on the server completely, because everything works on the frontend.
PS I looked at Jade, I will now switch from HAML, I don't like these things from the world of Ruby. I wish I could replace CoffeeScript with a hundred, but with a ternary operator...) Thanks, @dk-web)

M
mr-molodoy, 2015-09-06
@mr-molodoy

Do you have php compiling jade?
If I understand correctly, you want to do something like this?

doctype html
html
  head
    style
      include style.css
  body
    <?php if (isHome() == 'index') { ?>
        h1 Index page
    <?php } else { ?>
        h1 <?= $page->title ?>
    <?php } ?>
    p Welcome to my super lame site.
    script
      include script.js

If I understood correctly, then - read whether the library that you use in php to compile Jade can take not the path to the template for rendering, but the content, if so, do something like this:
function renderJade($file) {
         $jadeCompiler = new Jade\Compiler;

         ob_start();
         include $file; // здесь Jade шаблон
         $jadeContent = ob_get_contents();

         $template = $jadeCompiler->compileContent($jadeContent);
         
         return $template;
     }

     print renderJade("path/to/jade/template.php" );

Of course, the library you use has a different initialization method and method names, but

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question