Skip to content

Cannot keep format source code in output file #7

Description

@NeoHoang

Hello,

I've been making a cli script for convert Pug to Twig template.

This is my code

<?php

include 'vendor/autoload.php';

if( empty($argv[1]) ) exit('Missing file parameter.');

$file = $argv[1];

$filename = basename($file, ".pug");
$path = dirname($file);

$ouputfile = $path . DIRECTORY_SEPARATOR . $filename . ".htm";

#var_dump($filename, $path, $ouputfile);

$content = PugToTwig::convert(file_get_contents($file));

#var_dump($content);                         

if ( !empty($content) ) file_put_contents($ouputfile, $content);

exit();

But I cannot keep format for output file.

<ul id="users">{% for user in users %}{% endfor %}<li class="user">{#  comment #}{{ user.name | e }}Email: {{ user.email | e }}<a href="{{ user.url | e }}">Home page</a><span>aky</span></li></ul>

Can you help me to keep format syntax for twig output file ?

Thanks a lot
Neo

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions