Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prettier-plugin-eex

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prettier-plugin-eex - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

lib/liveview.js

12

CHANGELOG.md

@@ -5,9 +5,15 @@ # Changelog

## v.0.2.0 - 7 February 2021
## v0.3.0 - 11 February 2021
## Changes
### Bug Fixes
- Properly formats liveview files with form_for expressions
## v0.2.0 - 7 February 2021
### Changes
- decoding/encoding logic has been extracted to prettier-html-templates package
## Fixed
### Bug Fixes

@@ -14,0 +20,0 @@ - In some cases expressions weren't decoded inside script tags

const { tokenizeHTML } = require('prettier-html-templates');
const expressionTypeMatcher = require('./expression_type_matcher');
const { encodeFormForExpressions } = require('./liveview');
function parse(text, parsers, options) {
return tokenizeHTML(text, /<%[\s\S]*?%>/gm, expressionTypeMatcher);
const { liveViewFormExpressions, textWithPlaceholders } = encodeFormForExpressions(text);
return {
tokens: tokenizeHTML(textWithPlaceholders, /<%[\s\S]*?%>/gm, expressionTypeMatcher),
liveViewFormExpressions,
};
}

@@ -7,0 +13,0 @@

@@ -5,6 +5,7 @@ const prettier = require('prettier');

const { formatEex } = require('./formatter');
const { liveViewFormForPlaceholder } = require('./liveview');
// args: path, print, textToDoc, options
function embed(path, _print, textToDoc, options) {
const tokens = path.stack[0];
const { tokens, liveViewFormExpressions } = path.stack[0];

@@ -18,9 +19,15 @@ const isTextWithExpressions = tokens.find((token) => token.type !== 'text');

const formattedTokens = formatEex(tokens, options);
const [text, expressionMap] = encodeExpressions(formattedTokens);
const [textWithPlaceholders, expressionMap] = encodeExpressions(formattedTokens);
const htmlDoc = textToDoc(text, { parser: 'html' });
const htmlDoc = textToDoc(textWithPlaceholders, { parser: 'html' });
const callback = decodeExpressions(expressionMap);
return mapDoc(htmlDoc, (doc) => {
let newDoc = doc;
if (doc === liveViewFormForPlaceholder) {
newDoc = liveViewFormExpressions.shift();
}
return mapDoc(htmlDoc, callback);
return callback(newDoc);
});
}

@@ -27,0 +34,0 @@

{
"name": "prettier-plugin-eex",
"version": "0.2.0",
"version": "0.3.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "Prettier plugin for .html.eex and .html.leex files",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc