RiFi2k / format-html-in-php

Basically this vscode extension uses all your standard configurations for html formatting, and your standard configurations for format on save, etc. It more or less works exactly how vscode should already work as it pertains to HTML in PHP files.
The Unlicense
33 stars 6 forks source link

Broken PHP syntax inside <script> tags in vscode #37

Closed abhijeetdhariwal closed 3 years ago

abhijeetdhariwal commented 4 years ago
                            <div id="contact-map"></div>

                            <script type="text/javascript">
                            /*=== initializate google map ====*/

                            function initMap() {

                                var styles = [{
                                        "featureType": "administrative",
                                        "elementType": "all",
                                        "stylers": [{
                                                "visibility": "on"
                                            },
                                            {
                                                "saturation": -100
                                            },
                                            {
                                                "lightness": 20
                                            }
                                        ]
                                    },
                                    {
                                        "featureType": "road",
                                        "elementType": "all",
                                        "stylers": [{
                                                "visibility": "on"
                                            },
                                            {
                                                "saturation": -100
                                            },
                                            {
                                                "lightness": 40
                                            }
                                        ]
                                    },
                                    {
                                        "featureType": "water",
                                        "elementType": "all",
                                        "stylers": [{
                                                "visibility": "on"
                                            },
                                            {
                                                "saturation": -10
                                            },
                                            {
                                                "lightness": 30
                                            }
                                        ]
                                    },
                                    {
                                        "featureType": "landscape.man_made",
                                        "elementType": "all",
                                        "stylers": [{
                                                "visibility": "simplified"
                                            },
                                            {
                                                "saturation": -60
                                            },
                                            {
                                                "lightness": 10
                                            }
                                        ]
                                    },
                                    {
                                        "featureType": "landscape.natural",
                                        "elementType": "all",
                                        "stylers": [{
                                                "visibility": "simplified"
                                            },
                                            {
                                                "saturation": -60
                                            },
                                            {
                                                "lightness": 60
                                            }
                                        ]
                                    },
                                    {
                                        "featureType": "poi",
                                        "elementType": "all",
                                        "stylers": [{
                                                "visibility": "off"
                                            },
                                            {
                                                "saturation": -100
                                            },
                                            {
                                                "lightness": 60
                                            }
                                        ]
                                    },
                                    {
                                        "featureType": "transit",
                                        "elementType": "all",
                                        "stylers": [{
                                                "visibility": "off"
                                            },
                                            {
                                                "saturation": -100
                                            },
                                            {
                                                "lightness": 60
                                            }
                                        ]
                                    }
                                ];

                                <
                                ?
                                php
                                if ($local_location) {
                                    ?
                                    >

                                    var myLatLng = {
                                        lat: < ? php echo esc_js($PIXAD_Autos - > get_meta(
                                            '_seller_location_lat')) ? > ,
                                        lng: < ? php echo esc_js($PIXAD_Autos - > get_meta(
                                            '_seller_location_long')) ? >
                                    };
                                    var address =
                                        "<?php echo esc_js($PIXAD_Autos->get_meta('_seller_location')) ?>";

                                    <
                                    ?
                                    php
                                }
                                elseif($global_location) {
                                        ?
                                        >

                                        var myLatLng = {
                                            lat: < ? php echo esc_js($validate[
                                                'seller-location-lat_def']) ? > ,
                                            lng: < ? php echo esc_js($validate[
                                                'seller-location-long_def']) ? >
                                        };
                                        var address =
                                            "<?php echo esc_js($validate['seller-location_def']) ?>";

                                        <
                                        ?
                                        php
                                    } ? >

                                    // Create a map object and specify the DOM element for display.
                                    var map = new google.maps.Map(document.getElementById(
                                        "contact-map"), {
                                        center: myLatLng,
                                        scrollwheel: false,
                                        zoom: 15
                                    });

                                var marker = new google.maps.Marker({
                                    position: myLatLng,
                                    map: map,
                                    title: address
                                });

                                map.setOptions({
                                    styles: styles
                                });

                            }
                            </script>
chriscoyier commented 4 years ago

Same issue...

<script>
  var articleYear = <?php the_time('Y') ?>;
</script>

Becomes...

<script>
var articleYear = < ? php the_time('Y') ? > ;
</script>
abhijeetdhariwal commented 4 years ago

Use like this

On Tue, 5 May 2020, 4:55 am Chris Coyier, notifications@github.com wrote:

Same issue...

Becomes...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/RiFi2k/format-html-in-php/issues/37#issuecomment-623759807, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACHC5DILOQYIMVMTAYU3ASTRP5FFDANCNFSM4LG3XYQQ .

kpmarino commented 4 years ago

see a problem with that solution. if the value is numeric there is no need for outer quotes.

bitwiseman commented 3 years ago

Duplicate of #31