Git Product home page Git Product logo

Comments (16)

julienma avatar julienma commented on July 23, 2024 2

Downgrading prettier to 2.2.1 did the trick:

   "devDependencies": {
-   "@prettier/plugin-ruby": "^1.5.5",
-   "prettier": "^2.3.1",
-   "prettier-plugin-erb": "^0.3.0",
+   "@prettier/plugin-ruby": "^1.6.0",
+   "prettier": "2.2.1",
+   "prettier-plugin-erb": "^0.4.0",
  },

Actually I also tried without upgrading prettier-plugin-erb to 0.4.0, and it still worked as expected (no [object Object] issue):

   "devDependencies": {
    "@prettier/plugin-ruby": "^1.5.5",
-   "prettier": "^2.3.1",
+   "prettier": "2.2.1",
    "prettier-plugin-erb": "^0.3.0",
  },

from prettier-plugin-erb.

adamzapasnik avatar adamzapasnik commented on July 23, 2024 1

I have located the problem, will fix it tomorrow hopefully. Thanks guys for reporting.

from prettier-plugin-erb.

adamzapasnik avatar adamzapasnik commented on July 23, 2024 1

sorry for the wait, @karthikkasturi

I've just released a fix, please check the version 0.3.0

from prettier-plugin-erb.

karthikkasturi avatar karthikkasturi commented on July 23, 2024

Current config:
"@prettier/plugin-ruby": "^1.5.5",
"prettier": "2.2.0",
"prettier-plugin-erb": "^0.2.0",

from prettier-plugin-erb.

gbp avatar gbp commented on July 23, 2024

Also seeing this, appears to be when the ERB tag is within double quotes:

      =====================================input======================================
      <a href="mailto:<%= contact_email %>"><%= contact_email %></a>

      =====================================output=====================================
    - <a href="mailto:<%= contact_email %>"><%= contact_email %></a>
    + <a href="mailto:[object Object]"><%= contact_email %></a>

      ================================================================================

from prettier-plugin-erb.

karthikkasturi avatar karthikkasturi commented on July 23, 2024

any update on this? or a workaround?

from prettier-plugin-erb.

marcuslilja avatar marcuslilja commented on July 23, 2024

I'm seeing the issue with [object Object] as well. But in another context.

With the following versions

{
  "@prettier/plugin-ruby": "1.5.5",
  "prettier": "2.2.1",
  "prettier-plugin-erb": "0.3.0"
}

Running prettier on this

<script>
  var custom = '<%= data.to_json %>';
</script>

would result in the following

<script>
  var custom = '[object Object]';
</script>

from prettier-plugin-erb.

adamzapasnik avatar adamzapasnik commented on July 23, 2024

@marcuslilja I'll try to resolve this one over the weekend, sorry for trouble

from prettier-plugin-erb.

marcuslilja avatar marcuslilja commented on July 23, 2024

@marcuslilja I'll try to resolve this one over the weekend, sorry for trouble

Thanks 👍

from prettier-plugin-erb.

michaelzim avatar michaelzim commented on July 23, 2024

Same issue also happens with <pre> elements.

Input:
<pre><%= 123 %></pre>

Output:
<pre>[object Object]</pre>

from prettier-plugin-erb.

julienma avatar julienma commented on July 23, 2024

Hey, chiming in to report the same issue, in another context:

Versions:

    "@prettier/plugin-ruby": "^1.5.5",
    "prettier": "^2.3.1",
    "prettier-plugin-erb": "^0.3.0",

Source:

  <div
    class="form-group mb-3"
    data-controller="avatar-field"
    data-avatar-field-fallback-image-value="<%= image_path "icons/user-astronaut-regular.svg" %>"
  >

Formatted output:

  <div
    class="form-group mb-3"
    data-controller="avatar-field"
    data-avatar-field-fallback-image-value="[object Object]"
  >

from prettier-plugin-erb.

adamzapasnik avatar adamzapasnik commented on July 23, 2024

Released a fix, please check 0.4.0.

from prettier-plugin-erb.

julienma avatar julienma commented on July 23, 2024

Thank you @adamzapasnik... but this seems worse :/

package.json:

   "devDependencies": {
-   "@prettier/plugin-ruby": "^1.5.5",
+   "@prettier/plugin-ruby": "^1.6.0",
    "prettier": "^2.3.1",
-   "prettier-plugin-erb": "^0.3.0",
+   "prettier-plugin-erb": "^0.4.0",
    "webpack-dev-server": "^3.11.2"
  },

Input:

  <div class="form-group mb-3">
    <%= form.label :name, "Full name" %>
    <%= form.text_field :name, value: params[:name] || customer.name, class: "form-control", placeholder: "First name + last name" %>
  </div>

  <div
    class="form-group mb-3" 
    data-controller="avatar-field"
    data-avatar-field-fallback-image-value="<%= image_path "icons/user-astronaut-regular.svg" %>"
  >

Output:

  <div class="form-group mb-3">
    <eext7 />
    <eext8 />
  </div>

  <div
    class="form-group mb-3"
    data-controller="avatar-field"
    data-avatar-field-fallback-image-value="eex9eex"
  >

from prettier-plugin-erb.

kblicharski avatar kblicharski commented on July 23, 2024

I am still having this problem even with the above package versions. It seems to only apply for ERB tags nested inside of specific other tags.

EDIT: Maybe it's broken for specific tag types? If I have an ERB tag inside of a <p> it's fine, but inside of a <title> it breaks.

from prettier-plugin-erb.

kblicharski avatar kblicharski commented on July 23, 2024

This issue is still present for all tag types present in this array.

https://github.com/adamzapasnik/prettier-html-templates/blob/master/lib/tokenizer.js#L39

from prettier-plugin-erb.

kvnloughead avatar kvnloughead commented on July 23, 2024

Still an issue inside <title> tags for these deps

{
  "devDependencies": {
    "@prettier/plugin-ruby": "1.5.5",
    "prettier": "2.2.0",
    "prettier-plugin-erb": "0.2.0"
  }
}

Also for 0.3.0. But it seems to work with 0.4.0.

from prettier-plugin-erb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.