yui / yuicompressor

YUI Compressor
http://yui.github.com/yuicompressor/
Other
3.01k stars 664 forks source link

preserve SSI #192

Open pacioos opened 9 years ago

pacioos commented 9 years ago

I see no way of preserving server-side includes (SSI). It would be nice if there was a flag (e.g. --preserve-ssi) to tell YUI Compressor to preserve content between tags. Currently it fails with errors when it encounters these in my JavaScript files. Can somebody add this as a new feature?, or provide hints on how I might modify YUI Compressor to accomplish this? Thanks!, John Maurer

tml commented 9 years ago

Wow - it never even came into my head that people might be running server-side include code through YUICompressor. Can you provide a sample file?

pacioos commented 9 years ago

Thanks, Joey. Here is a simplified example illustrating a list of users defined: (1.) via inline JavaScript, and (2.) via an external SSI file. Each uses the browser console to dump result for testing.

// Example defining users inline:

var users = [];
var account = 'account_a';

if ( account == 'account_a' ) {
  users = [
    {
      "id": "kfarro", 
      "name": "Kyle Farro",
      "account": 1238890
    },
    {
       "id": "tmathis",
       "name": "Tom Mathis",
       "account": 5558743 
    },
    {
       "id": "vhampton",
       "name": "Violet Hampton",
       "account": 5573489 
    }
  ];
  console.info( users );
}

// Example defining users via external SSI:

var users = [];
var account = 'account_b';

if ( account == 'account_b' ) {
  <!--#include file="ssi/account_b.ssi" -->
  console.info( users );
}

This assumes that the file "ssi/account_b.ssi" contains the following JavaScript:

users = [
    {
        "id": "jsmith", 
        "name": "John Smith",
        "account": 1248972
    },
    {
        "id": "jdoe",
        "name": "Jane Doe",
        "account": 4529870
    },
    {
        "id": "kclark",
        "name": "Kerry Clark",
        "account": 2333709
    }
];